[Expat-checkins] expat/lib xmltok.c,1.16,1.17

kwaclaw@users.sourceforge.net kwaclaw@users.sourceforge.net
Sun Jun 9 07:02:08 2002


Update of /cvsroot/expat/expat/lib
In directory usw-pr-cvs1:/tmp/cvs-serv11614

Modified Files:
	xmltok.c 
Log Message:
Fix for bug # 566240.

Index: xmltok.c
===================================================================
RCS file: /cvsroot/expat/expat/lib/xmltok.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- xmltok.c	30 May 2002 18:02:59 -0000	1.16
+++ xmltok.c	9 Jun 2002 14:01:47 -0000	1.17
@@ -67,7 +67,9 @@
      : 0))
 
 /* Detection of invalid UTF-8 sequences is based on Table 3.1B
-   of Unicode 3.2: http://www.unicode.org/unicode/reports/tr28/.
+   of Unicode 3.2: http://www.unicode.org/unicode/reports/tr28/
+   with the additional restriction of not allowing the Unicode
+   code points 0xFFFF and 0xFFFE (sequences EF,BF,BF and EF,BF,BE).
    Implementation details:
      (A & 0x80) == 0     means A < 0x80
    and
@@ -78,7 +80,9 @@
   ((*p) < 0xC2 || ((p)[1] & 0x80) == 0 || ((p)[1] & 0xC0) == 0xC0)
 
 #define UTF8_INVALID3(p) \
-  (((p)[2] & 0x80) == 0 || ((p)[2] & 0xC0) == 0xC0 \
+  (((p)[2] & 0x80) == 0 \
+  || \
+  ((*p) == 0xEF ? (p)[2] > 0xBD : ((p)[2] & 0xC0) == 0xC0) \
   || \
   ((*p) == 0xE0 \
     ? \