#64235, 25037 illegal 0xA0 code point in Multibyte charset break parser

r=ftang, sr=erik
uscan.c
nsUnicodeDecodeHelper.cpp
nsGB2312ToUnicodeV2.cpp
nsGBKToUnicode.cpp
nsJapaneseToUnicode.cpp
This commit is contained in:
shanjian%netscape.com 2006-05-17 02:33:22 +00:00
Родитель c71bb0159b
Коммит 97c91ea3a1
2 изменённых файлов: 39 добавлений и 26 удалений

Просмотреть файл

@ -168,25 +168,34 @@ NS_IMETHODIMP nsUnicodeDecodeHelper::ConvertByMultiTable(
if ((aRangeArray[i].min <= *src) && (*src <= aRangeArray[i].max)) break;
if (i == aTableCount) {
src++;
res = NS_ERROR_UDEC_ILLEGALINPUT;
break;
if (*src == (PRUint8)0xa0)
*dest = 0x00a0;
else
*dest = 0xfffd;
bcr = 1;
}
if (!uScan(aShiftTable[i], NULL, src, NS_REINTERPRET_CAST(PRUint16*, &med), srcLen,
(PRUint32 *)&bcr)) {
res = NS_OK_UDEC_MOREINPUT;
break;
}
if (!uMapCode((uTable*) aMappingTable[i], NS_STATIC_CAST(PRUint16, med), NS_REINTERPRET_CAST(PRUint16*, dest))) {
if (med < 0x20) {
// somehow some table miss the 0x00 - 0x20 part
*dest = med;
} else {
// Unicode replacement value for unmappable chars
*dest = 0xfffd;
}
else
{
if (!uScan(aShiftTable[i], NULL, src, NS_REINTERPRET_CAST(PRUint16*, &med), srcLen,
(PRUint32 *)&bcr)) {
res = NS_OK_UDEC_MOREINPUT;
break;
}
if (!uMapCode((uTable*) aMappingTable[i], NS_STATIC_CAST(PRUint16, med), NS_REINTERPRET_CAST(PRUint16*, dest))) {
if (med < 0x20) {
// somehow some table miss the 0x00 - 0x20 part
*dest = med;
} else {
// 2 for EUC-KR code set 1 and EUC-JP codeset 1 and 2
// 3 for EUC-JP codeset 3, 4 for EUC-TW code set 3(CNS 11643 Plane 2 - 7)
if (bcr >= 2 && !(*(src+1) & 0x80) ) {
bcr-= (bcr-1);
}
// If stand-alone 0xa0 gets this far (BIG5), leave it alone.
// Otherwise, use Unicode replacement value for unmappable chars
*dest = (*src == (PRUint8)0xa0 ) ? 0x00a0 : 0xfffd;
}
}
}
src += bcr;

Просмотреть файл

@ -20,6 +20,8 @@
* Contributor(s):
*/
#include "unicpriv.h"
#define CHK_GR94(b) ( (PRUint8) 0xa0 < (PRUint8) (b) && (PRUint8) (b) < (PRUint8) 0xff )
#define CHK_GR94_2Byte(b1,b2) (CHK_GR94(b1) && CHK_GR94(b2))
/*=================================================================================
=================================================================================*/
@ -393,7 +395,9 @@ PRIVATE PRBool uCheckAndScanAlways2ByteShiftGR(
PRUint32* inscanlen
)
{
if(inbuflen < 2)
// Both bytes should be in the range of [0xa1,0xfe] for 94x94 character sets
// invoked on GR. No encoding implemented in Mozilla uses 96x96 char. sets.
if(inbuflen < 2 || ! CHK_GR94_2Byte(in[1],in[0]))
return PR_FALSE;
else
{
@ -445,7 +449,7 @@ PRIVATE PRBool uCheckAndScan2ByteGRPrefix8F(
PRUint32* inscanlen
)
{
if((inbuflen < 3) ||(in[0] != 0x8F))
if((inbuflen < 3) ||(in[0] != 0x8F) || ! CHK_GR94_2Byte(in[1],in[2]))
return PR_FALSE;
else
{
@ -466,7 +470,7 @@ PRIVATE PRBool uCheckAndScan2ByteGRPrefix8EA2(
PRUint32* inscanlen
)
{
if((inbuflen < 4) || (in[0] != 0x8E) || (in[1] != 0xA2))
if((inbuflen < 4) || (in[0] != 0x8E) || (in[1] != 0xA2) || ! CHK_GR94_2Byte(in[2],in[3]))
return PR_FALSE;
else
{
@ -558,7 +562,7 @@ PRIVATE PRBool uCheckAndScan2ByteGRPrefix8EA3(
PRUint32* inscanlen
)
{
if((inbuflen < 4) || (in[0] != 0x8E) || (in[1] != 0xA3))
if((inbuflen < 4) || (in[0] != 0x8E) || (in[1] != 0xA3) || ! CHK_GR94_2Byte(in[2],in[3]))
return PR_FALSE;
else
{
@ -579,7 +583,7 @@ PRIVATE PRBool uCheckAndScan2ByteGRPrefix8EA4(
PRUint32* inscanlen
)
{
if((inbuflen < 4) || (in[0] != 0x8E) || (in[1] != 0xA4))
if((inbuflen < 4) || (in[0] != 0x8E) || (in[1] != 0xA4) || ! CHK_GR94_2Byte(in[2],in[3]))
return PR_FALSE;
else
{
@ -600,7 +604,7 @@ PRIVATE PRBool uCheckAndScan2ByteGRPrefix8EA5(
PRUint32* inscanlen
)
{
if((inbuflen < 4) || (in[0] != 0x8E) || (in[1] != 0xA5))
if((inbuflen < 4) || (in[0] != 0x8E) || (in[1] != 0xA5) || ! CHK_GR94_2Byte(in[2],in[3]))
return PR_FALSE;
else
{
@ -621,7 +625,7 @@ PRIVATE PRBool uCheckAndScan2ByteGRPrefix8EA6(
PRUint32* inscanlen
)
{
if((inbuflen < 4) || (in[0] != 0x8E) || (in[1] != 0xA6))
if((inbuflen < 4) || (in[0] != 0x8E) || (in[1] != 0xA6) || ! CHK_GR94_2Byte(in[2],in[3]))
return PR_FALSE;
else
{
@ -642,7 +646,7 @@ PRIVATE PRBool uCheckAndScan2ByteGRPrefix8EA7(
PRUint32* inscanlen
)
{
if((inbuflen < 4) || (in[0] != 0x8E) || (in[1] != 0xA7))
if((inbuflen < 4) || (in[0] != 0x8E) || (in[1] != 0xA7) || ! CHK_GR94_2Byte(in[2],in[3]))
return PR_FALSE;
else
{