Ignore:
Timestamp:
Jul 9, 2016, 12:33:28 AM (9 years ago)
Author:
[email protected]
Message:

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

Patch by Benjamin Poulain <[email protected]> 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:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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);
Note: See TracChangeset for help on using the changeset viewer.