Changeset 203028 in webkit


Ignore:
Timestamp:
Jul 9, 2016, 12:33:28 AM (9 years ago)
Author:
commit-queue@webkit.org
Message:

[JSC] Fix the Template Raw Value of \ (escape) + LineTerminatorSequence
https://bugs.webkit.org/show_bug.cgi?id=159595

Patch by Benjamin Poulain <bpoulain@apple.com> on 2016-07-09
Reviewed by Yusuke Suzuki.

The spec (https://tc39.github.io/ecma262/#sec-static-semantics-tv-and-trv)
says:
"The TRV of LineContinuation::\LineTerminatorSequence is the sequence

consisting of the code unit value 0x005C followed by the code units
of TRV of LineTerminatorSequence."

We were not normalizing the LineTerminatorSequence in that case, but it should
be as it is the TRV of LineTerminatorSequence.

  • parser/Lexer.cpp:

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

  • tests/stress/tagged-templates-raw-strings.js:
Location:
trunk/Source/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r203015 r203028  
     12016-07-09  Benjamin Poulain  <bpoulain@apple.com>
     2
     3        [JSC] Fix the Template Raw Value of \ (escape) + LineTerminatorSequence
     4        https://bugs.webkit.org/show_bug.cgi?id=159595
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        The spec (https://tc39.github.io/ecma262/#sec-static-semantics-tv-and-trv)
     9        says:
     10        "The TRV of LineContinuation::\LineTerminatorSequence is the sequence
     11         consisting of the code unit value 0x005C followed by the code units
     12         of TRV of LineTerminatorSequence."
     13       
     14        We were not normalizing the LineTerminatorSequence in that case, but it should
     15        be as it is the TRV of LineTerminatorSequence.
     16
     17        * parser/Lexer.cpp:
     18        (JSC::Lexer<T>::parseTemplateLiteral):
     19        * tests/stress/tagged-templates-raw-strings.js:
     20
    1212016-07-08  Saam Barati  <sbarati@apple.com>
    222
  • trunk/Source/JavaScriptCore/parser/Lexer.cpp

    r202768 r203028  
    13941394                shift();
    13951395            } else if (UNLIKELY(isLineTerminator(m_current))) {
     1396                // Normalize <CR>, <CR><LF> to <LF>.
    13961397                if (m_current == '\r') {
     1398                    if (shouldBuildStrings) {
     1399                        ASSERT_WITH_MESSAGE(rawStringStart != currentSourcePtr(), "We should have at least shifted the escape.");
     1400
     1401                        if (rawStringsBuildMode == RawStringsBuildMode::BuildRawStrings) {
     1402                            m_bufferForRawTemplateString16.append(rawStringStart, currentSourcePtr() - rawStringStart);
     1403                            m_bufferForRawTemplateString16.append('\n');
     1404                        }
     1405                    }
     1406
    13971407                    lineNumberAdder.add(m_current);
    13981408                    shift();
     
    14011411                        shift();
    14021412                    }
     1413
     1414                    rawStringStart = currentSourcePtr();
    14031415                } else {
    14041416                    lineNumberAdder.add(m_current);
  • trunk/Source/JavaScriptCore/tests/stress/tagged-templates-raw-strings.js

    r184337 r203028  
    5454
    5555testEval("Hello\\\n\r\rWorld", [ "Hello\\\n\n\nWorld" ]);
    56 testEval("Hello\\\r\n\n\nWorld", [ "Hello\\\r\n\n\nWorld" ]);
     56testEval("Hello\\\r\n\n\nWorld", [ "Hello\\\n\n\nWorld" ]);
    5757testEval("Hello\\\n\r\n\nWorld", [ "Hello\\\n\n\nWorld" ]);
    5858testEval("Hello\\\n\r\r\nWorld", [ "Hello\\\n\n\nWorld" ]);
Note: See TracChangeset for help on using the changeset viewer.