зеркало из https://github.com/mozilla/gecko-dev.git
fix for bug 26938. r=tao a=ftang. fix \u encoding conversion so \n \r \t\ will be
convert to \n \r \t
This commit is contained in:
Родитель
a62381980b
Коммит
1eb8f9143f
|
@ -104,6 +104,17 @@ NS_IMETHODIMP nsUEscapeToUnicode::Convert(
|
|||
if(('u' == *srcPtr) || ('U' == *srcPtr)) {
|
||||
mState++;
|
||||
mData=0;
|
||||
} else if(('n' == *srcPtr) || ('r' == *srcPtr) || ('t' == *srcPtr)) {
|
||||
mState =0;
|
||||
if((destPtr+2) >= destEnd) {
|
||||
// notice the data in mBuffer is stored in reversed order
|
||||
mBufferLen = 2;
|
||||
mBuffer[1] = PRUnichar('\\') ;
|
||||
mBuffer[0] = (PRUnichar)*srcPtr;
|
||||
goto error;
|
||||
}
|
||||
*destPtr++ = PRUnichar('\\');
|
||||
*destPtr++ = (PRUnichar)*srcPtr;
|
||||
} else {
|
||||
mState =0;
|
||||
*destPtr++ = (PRUnichar)*srcPtr;
|
||||
|
|
|
@ -101,10 +101,17 @@ NS_IMETHODIMP nsUnicodeToUEscape::Convert(const PRUnichar * aSrc, PRInt32 * aSrc
|
|||
{
|
||||
if( PRUnichar('\\') == *src)
|
||||
{
|
||||
if((dest +2 ) >= destEnd)
|
||||
goto error;
|
||||
*dest++ = (char) '\\';
|
||||
*dest++ = (char) '\\';
|
||||
if(( PRUnichar('n') == *(1+src))||
|
||||
( PRUnichar('r') == *(1+src))||
|
||||
( PRUnichar('t') == *(1+src)))
|
||||
{
|
||||
*dest++ = (char) *src;
|
||||
} else {
|
||||
if((dest +2 ) >= destEnd)
|
||||
goto error;
|
||||
*dest++ = (char) '\\';
|
||||
*dest++ = (char) '\\';
|
||||
}
|
||||
} else {
|
||||
*dest++ = (char) *src;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче