Diff
Modified: trunk/JSTests/ChangeLog (219262 => 219263)
--- trunk/JSTests/ChangeLog 2017-07-07 19:36:08 UTC (rev 219262)
+++ trunk/JSTests/ChangeLog 2017-07-07 19:50:00 UTC (rev 219263)
@@ -1,3 +1,13 @@
+2017-07-07 Mark Lam <[email protected]>
+
+ \n\r is not the same as \r\n.
+ https://bugs.webkit.org/show_bug.cgi?id=173053
+
+ Reviewed by Keith Miller.
+
+ * stress/regress-173053.js: Added.
+ * stress/template-literal-line-terminators.js:
+
2017-07-06 Saam Barati <[email protected]>
We are missing places where we invalidate the for-in context
Added: trunk/JSTests/stress/regress-173053.js (0 => 219263)
--- trunk/JSTests/stress/regress-173053.js (rev 0)
+++ trunk/JSTests/stress/regress-173053.js 2017-07-07 19:50:00 UTC (rev 219263)
@@ -0,0 +1,19 @@
+var exception;
+
+try {
+ eval("'\\\r\n'");
+} catch (e) {
+ exception = e;
+}
+
+if (exception)
+ throw "FAILED: \\r\\n should be handled as a line terminator";
+
+try {
+ eval("'\\\n\r'");
+} catch (e) {
+ exception = e;
+}
+
+if (exception != "SyntaxError: Unexpected EOF")
+ throw "FAILED: \\n\\r should NOT be handled as a line terminator. Expected exception: 'SyntaxError: Unexpected EOF', actual: '" + exception + "'";
Modified: trunk/JSTests/stress/template-literal-line-terminators.js (219262 => 219263)
--- trunk/JSTests/stress/template-literal-line-terminators.js 2017-07-07 19:36:08 UTC (rev 219262)
+++ trunk/JSTests/stress/template-literal-line-terminators.js 2017-07-07 19:50:00 UTC (rev 219263)
@@ -1,7 +1,7 @@
function test(actual, expected) {
if (actual !== expected)
- throw new Error("bad value: " + actual);
+ throw new Error("bad value: actual: " + actual + ", expected: " + expected);
}
function testEval(script, expected) {
@@ -36,20 +36,20 @@
testEvalLineNumber("`Hello\r\rWorld`", "Hello\n\nWorld", 3);
testEvalLineNumber("`Hello\r\nWorld`", "Hello\nWorld", 2);
testEvalLineNumber("`Hello\n\nWorld`", "Hello\n\nWorld", 3);
-testEvalLineNumber("`Hello\n\rWorld`", "Hello\n\nWorld", 2);
+testEvalLineNumber("`Hello\n\rWorld`", "Hello\n\nWorld", 3);
testEvalLineNumber("`Hello\n\r\nWorld`", "Hello\n\nWorld", 3);
testEvalLineNumber("`Hello\r\n\rWorld`", "Hello\n\nWorld", 3);
testEvalLineNumber("`Hello\n\n\nWorld`", "Hello\n\n\nWorld", 4);
-testEvalLineNumber("`Hello\n\r\n\rWorld`", "Hello\n\n\nWorld", 3);
+testEvalLineNumber("`Hello\n\r\n\rWorld`", "Hello\n\n\nWorld", 4);
testEvalLineNumber("`Hello\n\r\n\nWorld`", "Hello\n\n\nWorld", 4);
testEvalLineNumber("`Hello\r\n\n\nWorld`", "Hello\n\n\nWorld", 4);
-testEvalLineNumber("`Hello\\\n\r\rWorld`", "Hello\n\nWorld", 3);
+testEvalLineNumber("`Hello\\\n\r\rWorld`", "Hello\n\nWorld", 4);
testEvalLineNumber("`Hello\\\r\n\n\nWorld`", "Hello\n\nWorld", 4);
testEvalLineNumber("`Hello\\\n\r\n\nWorld`", "Hello\n\nWorld", 4);
-testEvalLineNumber("`Hello\\\n\r\r\nWorld`", "Hello\n\nWorld", 3);
+testEvalLineNumber("`Hello\\\n\r\r\nWorld`", "Hello\n\nWorld", 4);
testEvalLineNumber("`\u2028`", "\u2028", 2);
testEvalLineNumber("`\u2029`", "\u2029", 2);
Modified: trunk/LayoutTests/ChangeLog (219262 => 219263)
--- trunk/LayoutTests/ChangeLog 2017-07-07 19:36:08 UTC (rev 219262)
+++ trunk/LayoutTests/ChangeLog 2017-07-07 19:50:00 UTC (rev 219263)
@@ -1,3 +1,13 @@
+2017-07-07 Mark Lam <[email protected]>
+
+ \n\r is not the same as \r\n.
+ https://bugs.webkit.org/show_bug.cgi?id=173053
+
+ Reviewed by Keith Miller.
+
+ * js/parse-backslash-before-newline-expected.txt:
+ * js/script-tests/parse-backslash-before-newline.js:
+
2017-07-07 Matt Lewis <[email protected]>
Unreviewed, rolling out r219256.
Modified: trunk/LayoutTests/js/parse-backslash-before-newline-expected.txt (219262 => 219263)
--- trunk/LayoutTests/js/parse-backslash-before-newline-expected.txt 2017-07-07 19:36:08 UTC (rev 219262)
+++ trunk/LayoutTests/js/parse-backslash-before-newline-expected.txt 2017-07-07 19:50:00 UTC (rev 219263)
@@ -1,5 +1,6 @@
PASS "teststring with CR LF" is "teststring with CR LF"
-PASS "teststring with LF CR" is "teststring with LF CR"
+PASS "test
+string with LF CR" threw exception SyntaxError: Unexpected EOF.
PASS "teststring with CR" is "teststring with CR"
PASS "teststring with LF" is "teststring with LF"
PASS successfullyParsed is true
Modified: trunk/LayoutTests/js/script-tests/parse-backslash-before-newline.js (219262 => 219263)
--- trunk/LayoutTests/js/script-tests/parse-backslash-before-newline.js 2017-07-07 19:36:08 UTC (rev 219262)
+++ trunk/LayoutTests/js/script-tests/parse-backslash-before-newline.js 2017-07-07 19:50:00 UTC (rev 219263)
@@ -1,9 +1,9 @@
shouldBe('"test\
string with CR LF"', '"teststring with CR LF"');
-shouldBe('"test\
+shouldThrow(`"test\
-string with LF CR"', '"teststring with LF CR"');
+string with LF CR"`, '"SyntaxError: Unexpected EOF"');
shouldBe('"test\ string with CR"', '"teststring with CR"');
Modified: trunk/Source/_javascript_Core/ChangeLog (219262 => 219263)
--- trunk/Source/_javascript_Core/ChangeLog 2017-07-07 19:36:08 UTC (rev 219262)
+++ trunk/Source/_javascript_Core/ChangeLog 2017-07-07 19:50:00 UTC (rev 219263)
@@ -1,3 +1,14 @@
+2017-07-07 Mark Lam <[email protected]>
+
+ \n\r is not the same as \r\n.
+ https://bugs.webkit.org/show_bug.cgi?id=173053
+
+ Reviewed by Keith Miller.
+
+ * parser/Lexer.cpp:
+ (JSC::Lexer<T>::shiftLineTerminator):
+ (JSC::LineNumberAdder::add):
+
2017-07-07 Commit Queue <[email protected]>
Unreviewed, rolling out r219238, r219239, and r219241.
Modified: trunk/Source/_javascript_Core/parser/Lexer.cpp (219262 => 219263)
--- trunk/Source/_javascript_Core/parser/Lexer.cpp 2017-07-07 19:36:08 UTC (rev 219262)
+++ trunk/Source/_javascript_Core/parser/Lexer.cpp 2017-07-07 19:50:00 UTC (rev 219263)
@@ -1,6 +1,6 @@
/*
* Copyright (C) 1999-2000 Harri Porten ([email protected])
- * Copyright (C) 2006-2009, 2011-2013, 2016 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2006-2017 Apple Inc. All Rights Reserved.
* Copyright (C) 2007 Cameron Zwarich ([email protected])
* Copyright (C) 2010 Zoltan Herczeg ([email protected])
* Copyright (C) 2012 Mathias Bynens ([email protected])
@@ -705,8 +705,7 @@
T prev = m_current;
shift();
- // Allow both CRLF and LFCR.
- if (prev + m_current == '\n' + '\r')
+ if (prev == '\r' && m_current == '\n')
shift();
++m_lineNumber;
@@ -1411,7 +1410,7 @@
void add(CharacterType character)
{
ASSERT(Lexer<CharacterType>::isLineTerminator(character));
- if ((character + m_previous) == ('\n' + '\r'))
+ if (m_previous == '\r' && character == '\n')
m_previous = 0;
else {
++m_lineNumber;