From 21ba749fb2636c59e66d180162088e8a018ebbe2 Mon Sep 17 00:00:00 2001 From: Jonas Sicking Date: Tue, 23 Feb 2010 09:38:10 -0800 Subject: [PATCH] Bug 541245 part 4: Be consistent about prohibited characters such as 0xFFFE in UTF8<->UTF16 conversion code. r=smontagu --- xpcom/string/public/nsUTF8Utils.h | 5 ++--- xpcom/tests/UTFStrings.h | 8 ++++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/xpcom/string/public/nsUTF8Utils.h b/xpcom/string/public/nsUTF8Utils.h index 3faf002c2695..8989bb9cfa36 100644 --- a/xpcom/string/public/nsUTF8Utils.h +++ b/xpcom/string/public/nsUTF8Utils.h @@ -134,10 +134,9 @@ public: ucs4 = UCS2_REPLACEMENT_CHAR; } else if ( ucs4 >= 0xD800 && - (ucs4 <= 0xDFFF || ucs4 == 0xFFFE || ucs4 == 0xFFFF || - ucs4 >= UCS_END)) + (ucs4 <= 0xDFFF || ucs4 >= UCS_END)) { - // Surrogates and prohibited characters + // Surrogates and code points outside the Unicode range. ucs4 = UCS2_REPLACEMENT_CHAR; } diff --git a/xpcom/tests/UTFStrings.h b/xpcom/tests/UTFStrings.h index cabd03197127..59e7c4b61652 100644 --- a/xpcom/tests/UTFStrings.h +++ b/xpcom/tests/UTFStrings.h @@ -61,6 +61,10 @@ static const UTFStringsStringPair ValidStrings[] = { 0xF0, 0x90, 0x80, 0x80, 0xF0, 0x90, 0x83, 0xBF } }, { { 0xDBFF, 0xDFFF, 0xDBB7, 0xDCBA }, { 0xF4, 0x8F, 0xBF, 0xBF, 0xF3, 0xBD, 0xB2, 0xBA } }, + { { 0xFFFD, 0xFFFF }, + { 0xEF, 0xBF, 0xBD, 0xEF, 0xBF, 0xBF } }, + { { 0xFFFD, 0xFFFE, 0xFFFF }, + { 0xEF, 0xBF, 0xBD, 0xEF, 0xBF, 0xBE, 0xEF, 0xBF, 0xBF } }, }; static const UTFStringsStringPair Invalid16Strings[] = @@ -95,10 +99,6 @@ static const UTFStringsStringPair Invalid8Strings[] = { 0xC1, 0xBF } }, { { 0xFFFD, 'x', 0x0800 }, { 0xE0, 0x80, 0x80, 'x', 0xE0, 0xA0, 0x80 } }, - { { 0xFFFD, 0xFFFD }, - { 0xEF, 0xBF, 0xBD, 0xEF, 0xBF, 0xBF } }, - { { 0xFFFD, 0xFFFD, 0xFFFD }, - { 0xEF, 0xBF, 0xBD, 0xEF, 0xBF, 0xBE, 0xEF, 0xBF, 0xBF } }, { { 0xFFFD, 'x', 0xFFFD }, { 0xF0, 0x80, 0x80, 0x80, 'x', 0xF0, 0x80, 0x8F, 0x80 } }, { { 0xFFFD, 0xFFFD },