Browse Source

* reject surrogate characters when decoding UTF-8 keyboard input

git-svn-id: branches/unicodekvm@41524 -
nickysn 6 years ago
parent
commit
982a4f4c63
1 changed files with 2 additions and 1 deletions
  1. 2 1
      packages/rtl-console/src/unix/keyboard.pp

+ 2 - 1
packages/rtl-console/src/unix/keyboard.pp

@@ -1456,7 +1456,8 @@ var
               if not IsValidUtf8ContinuationByte(ch) then
               if not IsValidUtf8ContinuationByte(ch) then
                 exit;
                 exit;
               CodePoint:=(Ord(ch) and %00111111) or CodePoint;
               CodePoint:=(Ord(ch) and %00111111) or CodePoint;
-              if (CodePoint>=$800) and (CodePoint<=$FFFF) then
+              if ((CodePoint>=$800) and (CodePoint<=$D7FF)) or
+                 ((CodePoint>=$E000) and (CodePoint<=$FFFF)) then
                 ReadUtf8:=CodePoint;
                 ReadUtf8:=CodePoint;
             end;
             end;
           4:begin
           4:begin