fix QUtf8 codec to disallow codes in range [U+fdd0..U+fdef]
authorKonstantin Ritt <ritt.ks@gmail.com>
Wed, 11 Apr 2012 14:33:22 +0000 (17:33 +0300)
committerQt by Nokia <qt-info@nokia.com>
Wed, 11 Apr 2012 17:14:43 +0000 (19:14 +0200)
0xfdef-0xfdd0 is definitely 31 and not 15 :)
also fix all copy-pastes of this code (greping for '0xfdd0' helps ;)

Change-Id: I8f3bd4fd9d85f9de066f0f5df378b9188c12bd48
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Denis Dzyubenko <denis.dzyubenko@nokia.com>
src/corelib/codecs/qutfcodec.cpp
src/corelib/json/qjsonparser.cpp
src/corelib/json/qjsonwriter.cpp
tests/auto/corelib/codecs/utf8/tst_utf8.cpp
tests/benchmarks/corelib/tools/qstring/main.cpp

index c7076ee..18d063a 100644 (file)
@@ -58,7 +58,7 @@ static inline bool isUnicodeNonCharacter(uint ucs4)
     // U+FDEF (inclusive)
 
     return (ucs4 & 0xfffe) == 0xfffe
-            || (ucs4 - 0xfdd0U) < 16;
+            || (ucs4 - 0xfdd0U) < 32;
 }
 
 QByteArray QUtf8::convertFromUnicode(const QChar *uc, int len, QTextCodec::ConverterState *state)
index 9b11c9a..7d25c81 100644 (file)
@@ -731,7 +731,7 @@ static inline bool isUnicodeNonCharacter(uint ucs4)
     // U+FDEF (inclusive)
 
     return (ucs4 & 0xfffe) == 0xfffe
-            || (ucs4 - 0xfdd0U) < 16;
+            || (ucs4 - 0xfdd0U) < 32;
 }
 
 static inline bool scanUtf8Char(const char *&json, const char *end, uint *result)
index d544e61..d392bd7 100644 (file)
@@ -61,7 +61,7 @@ static inline bool isUnicodeNonCharacter(uint ucs4)
     // U+FDEF (inclusive)
 
     return (ucs4 & 0xfffe) == 0xfffe
-            || (ucs4 - 0xfdd0U) < 16;
+            || (ucs4 - 0xfdd0U) < 32;
 }
 
 static inline uchar hexdig(uint u)
index b80ba8e..c0ed152 100644 (file)
@@ -321,7 +321,7 @@ void tst_Utf8::nonCharacters_data()
     // U+FDEF (inclusive)
 
     // U+FDD0 through U+FDEF
-    for (int i = 0; i < 16; ++i) {
+    for (int i = 0; i < 32; ++i) {
         char utf8[] = { char(0357), char(0267), char(0220 + i), 0 };
         QString utf16 = QChar(0xfdd0 + i);
         QTest::newRow(qPrintable(QString::number(0xfdd0 + i, 16))) << QByteArray(utf8) << utf16;
index 9b10e97..40300af 100644 (file)
@@ -1944,7 +1944,7 @@ static inline bool isUnicodeNonCharacter(uint ucs4)
     // U+FDEF (inclusive)
 
     return (ucs4 & 0xfffe) == 0xfffe
-            || (ucs4 - 0xfdd0U) < 16;
+            || (ucs4 - 0xfdd0U) < 32;
 }
 
 int fromUtf8_qt47(ushort *dst, const char *chars, int len)