Ignore:
Timestamp:
Mar 13, 2012, 7:12:25 PM (13 years ago)
Author:
[email protected]
Message:

Type conversion of exponential part failed
https://bugs.webkit.org/show_bug.cgi?id=80673

Reviewed by Geoffrey Garen.

  • parser/Lexer.cpp:

(JSC::::lex):

  • runtime/JSGlobalObjectFunctions.cpp:

(JSC::parseInt):
(JSC):
(JSC::jsStrDecimalLiteral): Added another template argument that exposes whether or not
we accept trailing junk to clients of jsStrDecimalLiteral. Also added additional template
parameter for strtod to allow trailing spaces.
(JSC::toDouble):
(JSC::parseFloat): Accept trailing junk, as per the ECMA 262 spec (15.1.2.3).

  • runtime/LiteralParser.cpp:

(JSC::::Lexer::lexNumber):

  • tests/mozilla/expected.html: Update the expected page for run-javascriptcore-tests so that

we will run ecma/TypeConversion/9.3.1-3.js as a regression test now.

  • wtf/dtoa.cpp:

(WTF):
(WTF::strtod): We also needed to sometimes accept trailing spaces to pass a few other tests that were
broken by changing the default allowance of trailing junk in jsStrDecimalLiteral.

  • wtf/dtoa.h:
  • wtf/dtoa/double-conversion.cc: When the AdvanceToNonspace function was lifted out of the

Chromium codebase, the person porting it only thought to check for spaces when skipping whitespace.
A few of our JSC tests check for other types of trailing whitespace, so I've added checks for those
here to cover those cases (horizontal tab, vertical tab, carriage return, form feed, and line feed).

  • wtf/text/WTFString.cpp:

(WTF::toDoubleType): Disallow trailing spaces, as this breaks form input verification stuff.

File:
1 edited

Legend:

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

    r110033 r110657  
    298298    if (number >= mantissaOverflowLowerBound) {
    299299        if (radix == 10)
    300             number = WTF::strtod<WTF::AllowTrailingJunk>(s.substringSharingImpl(firstDigitPosition, p - firstDigitPosition).utf8().data(), 0);
     300            number = WTF::strtod<WTF::AllowTrailingJunk, WTF::DisallowTrailingSpaces>(s.substringSharingImpl(firstDigitPosition, p - firstDigitPosition).utf8().data(), 0);
    301301        else if (radix == 2 || radix == 4 || radix == 8 || radix == 16 || radix == 32)
    302302            number = parseIntOverflow(s.substringSharingImpl(firstDigitPosition, p - firstDigitPosition).utf8().data(), p - firstDigitPosition, radix);
     
    357357
    358358// See ecma-262 9.3.1
    359 template <typename CharType>
     359template <WTF::AllowTrailingJunkTag allowTrailingJunk, typename CharType>
    360360static double jsStrDecimalLiteral(const CharType*& data, const CharType* end)
    361361{
     
    370370    byteBuffer.append(0);
    371371    char* endOfNumber;
    372     double number = WTF::strtod<WTF::AllowTrailingJunk>(byteBuffer.data(), &endOfNumber);
     372    double number = WTF::strtod<allowTrailingJunk, WTF::AllowTrailingSpaces>(byteBuffer.data(), &endOfNumber);
    373373
    374374    // Check if strtod found a number; if so return it.
     
    426426        number = jsHexIntegerLiteral(characters, endCharacters);
    427427    else
    428         number = jsStrDecimalLiteral(characters, endCharacters);
     428        number = jsStrDecimalLiteral<WTF::DisallowTrailingJunk>(characters, endCharacters);
    429429   
    430430    // Allow trailing white space.
     
    483483            return std::numeric_limits<double>::quiet_NaN();
    484484
    485         return jsStrDecimalLiteral(data, end);
     485        return jsStrDecimalLiteral<WTF::AllowTrailingJunk>(data, end);
    486486    }
    487487
     
    499499        return std::numeric_limits<double>::quiet_NaN();
    500500
    501     return jsStrDecimalLiteral(data, end);
     501    return jsStrDecimalLiteral<WTF::AllowTrailingJunk>(data, end);
    502502}
    503503
Note: See TracChangeset for help on using the changeset viewer.