Ignore:
Timestamp:
Jan 29, 2018, 11:34:44 PM (7 years ago)
Author:
Yusuke Suzuki
Message:

[JSC] Relax line terminators in String to make JSON subset of JS
https://bugs.webkit.org/show_bug.cgi?id=182232

Reviewed by Keith Miller.

JSTests:

  • ChakraCore/test/es5/Lex_u3.baseline-jsc:
  • stress/relaxed-line-terminators-in-string.js: Added.

(shouldBe):

Source/JavaScriptCore:

"Subsume JSON" spec is now stage 3[1]. Before this spec change,
JSON can accept \u2028 / \u2029 in string while JS cannot do that.
It accidentally made JSON non subset of JS.

Now we extend our JS string to accept \u2028 / \u2029 to make JSON
subset of JS in this spec change.

[1]: https://github.com/tc39/proposal-json-superset

  • parser/Lexer.cpp:

(JSC::Lexer<T>::parseStringSlowCase):

LayoutTests:

  • sputnik/Conformance/07_Lexical_Conventions/7.3_Line_Terminators/S7.3_A2.3-expected.txt:
  • sputnik/Conformance/07_Lexical_Conventions/7.3_Line_Terminators/S7.3_A2.3.html:
  • sputnik/Conformance/07_Lexical_Conventions/7.3_Line_Terminators/S7.3_A2.4-expected.txt:
  • sputnik/Conformance/07_Lexical_Conventions/7.3_Line_Terminators/S7.3_A2.4.html:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/parser/Lexer.cpp

    r225799 r227775  
    13561356        }
    13571357        // Fast check for characters that require special handling.
    1358         // Catches 0, \n, \r, 0x2028, and 0x2029 as efficiently
    1359         // as possible, and lets through all common ASCII characters.
    1360         if (UNLIKELY(((static_cast<unsigned>(m_current) - 0xE) & 0x2000))) {
     1358        // Catches 0, \n, and \r as efficiently as possible, and lets through all common ASCII characters.
     1359        static_assert(std::is_unsigned<T>::value, "Lexer expects an unsigned character type");
     1360        if (UNLIKELY(m_current < 0xE)) {
    13611361            // New-line or end of input is not allowed
    1362             if (atEnd() || isLineTerminator(m_current)) {
     1362            if (atEnd() || m_current == '\r' || m_current == '\n') {
    13631363                m_lexErrorMessage = ASCIILiteral("Unexpected EOF");
    13641364                return atEnd() ? StringUnterminated : StringCannotBeParsed;
Note: See TracChangeset for help on using the changeset viewer.