Ignore:
Timestamp:
Dec 6, 2011, 2:41:56 PM (14 years ago)
Author:
[email protected]
Message:

r102146 from 73875 broke fast/js/encode-URI-test.html
https://bugs.webkit.org/show_bug.cgi?id=73950

Reviewed by Gavin Barraclough.

  • runtime/JSGlobalObjectFunctions.cpp:

(JSC::globalFuncUnescape): Restructured to handle
the %uHHHH case to output the resulting character
and continue so that a failure in finding 4 hex
digits will fall through and output the '%'.
Due to style check, changed the temporary
character variable to a more descriptive name.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp

    r102146 r102182  
    647647    if (str.is8Bit()) {
    648648        const LChar* characters = str.characters8();
    649 
     649        LChar convertedLChar;
    650650        while (k < len) {
    651651            const LChar* c = characters + k;
     
    653653                if (isASCIIHexDigit(c[2]) && isASCIIHexDigit(c[3]) && isASCIIHexDigit(c[4]) && isASCIIHexDigit(c[5])) {
    654654                    builder.append(Lexer<UChar>::convertUnicode(c[2], c[3], c[4], c[5]));
    655                     k += 5;
     655                    k += 6;
     656                    continue;
    656657                }
    657658            } else if (c[0] == '%' && k <= len - 3 && isASCIIHexDigit(c[1]) && isASCIIHexDigit(c[2])) {
    658                 builder.append(Lexer<LChar>::convertHex(c[1], c[2]));
     659                convertedLChar = LChar(Lexer<LChar>::convertHex(c[1], c[2]));
     660                c = &convertedLChar;
    659661                k += 2;
    660             } else
    661                 builder.append(*c);
     662            }
     663            builder.append(*c);
    662664            k++;
    663665        }       
     
    667669        while (k < len) {
    668670            const UChar* c = characters + k;
    669             UChar u;
     671            UChar convertedUChar;
    670672            if (c[0] == '%' && k <= len - 6 && c[1] == 'u') {
    671673                if (isASCIIHexDigit(c[2]) && isASCIIHexDigit(c[3]) && isASCIIHexDigit(c[4]) && isASCIIHexDigit(c[5])) {
    672                     u = Lexer<UChar>::convertUnicode(c[2], c[3], c[4], c[5]);
    673                     c = &u;
     674                    convertedUChar = Lexer<UChar>::convertUnicode(c[2], c[3], c[4], c[5]);
     675                    c = &convertedUChar;
    674676                    k += 5;
    675677                }
    676678            } else if (c[0] == '%' && k <= len - 3 && isASCIIHexDigit(c[1]) && isASCIIHexDigit(c[2])) {
    677                 u = UChar(Lexer<UChar>::convertHex(c[1], c[2]));
    678                 c = &u;
     679                convertedUChar = UChar(Lexer<UChar>::convertHex(c[1], c[2]));
     680                c = &convertedUChar;
    679681                k += 2;
    680682            }
Note: See TracChangeset for help on using the changeset viewer.