Title: [203028] trunk/Source/_javascript_Core
Revision
203028
Author
[email protected]
Date
2016-07-09 00:33:28 -0700 (Sat, 09 Jul 2016)

Log 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:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (203027 => 203028)


--- trunk/Source/_javascript_Core/ChangeLog	2016-07-09 06:37:38 UTC (rev 203027)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-07-09 07:33:28 UTC (rev 203028)
@@ -1,3 +1,23 @@
+2016-07-09  Benjamin Poulain  <[email protected]>
+
+        [JSC] Fix the Template Raw Value of \ (escape) + LineTerminatorSequence
+        https://bugs.webkit.org/show_bug.cgi?id=159595
+
+        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:
+
 2016-07-08  Saam Barati  <[email protected]>
 
         We may add a ReadOnly property without setting the corresponding bit on Structure

Modified: trunk/Source/_javascript_Core/parser/Lexer.cpp (203027 => 203028)


--- trunk/Source/_javascript_Core/parser/Lexer.cpp	2016-07-09 06:37:38 UTC (rev 203027)
+++ trunk/Source/_javascript_Core/parser/Lexer.cpp	2016-07-09 07:33:28 UTC (rev 203028)
@@ -1393,7 +1393,17 @@
                     record16(escape);
                 shift();
             } else if (UNLIKELY(isLineTerminator(m_current))) {
+                // Normalize <CR>, <CR><LF> to <LF>.
                 if (m_current == '\r') {
+                    if (shouldBuildStrings) {
+                        ASSERT_WITH_MESSAGE(rawStringStart != currentSourcePtr(), "We should have at least shifted the escape.");
+
+                        if (rawStringsBuildMode == RawStringsBuildMode::BuildRawStrings) {
+                            m_bufferForRawTemplateString16.append(rawStringStart, currentSourcePtr() - rawStringStart);
+                            m_bufferForRawTemplateString16.append('\n');
+                        }
+                    }
+
                     lineNumberAdder.add(m_current);
                     shift();
                     if (m_current == '\n') {
@@ -1400,6 +1410,8 @@
                         lineNumberAdder.add(m_current);
                         shift();
                     }
+
+                    rawStringStart = currentSourcePtr();
                 } else {
                     lineNumberAdder.add(m_current);
                     shift();

Modified: trunk/Source/_javascript_Core/tests/stress/tagged-templates-raw-strings.js (203027 => 203028)


--- trunk/Source/_javascript_Core/tests/stress/tagged-templates-raw-strings.js	2016-07-09 06:37:38 UTC (rev 203027)
+++ trunk/Source/_javascript_Core/tests/stress/tagged-templates-raw-strings.js	2016-07-09 07:33:28 UTC (rev 203028)
@@ -53,7 +53,7 @@
 testEval("Hello\r\n\n\nWorld", [ "Hello\n\n\nWorld" ]);
 
 testEval("Hello\\\n\r\rWorld", [ "Hello\\\n\n\nWorld" ]);
-testEval("Hello\\\r\n\n\nWorld", [ "Hello\\\r\n\n\nWorld" ]);
+testEval("Hello\\\r\n\n\nWorld", [ "Hello\\\n\n\nWorld" ]);
 testEval("Hello\\\n\r\n\nWorld", [ "Hello\\\n\n\nWorld" ]);
 testEval("Hello\\\n\r\r\nWorld", [ "Hello\\\n\n\nWorld" ]);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to