Bug 541245 part 4: Be consistent about prohibited characters such as 0xFFFE in UTF8<->UTF16 conversion code. r=smontagu

This commit is contained in:
Jonas Sicking 2010-02-23 09:38:10 -08:00
parent 912342472e
commit 21ba749fb2
2 changed files with 6 additions and 7 deletions

View File

@ -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;
}

View File

@ -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 },