https://bugs.webkit.org/show_bug.cgi?id=173053
Reviewed by Keith Miller.
JSTests:
* stress/regress-173053.js: Added.
* stress/template-literal-line-terminators.js:
Source/JavaScriptCore:
* parser/Lexer.cpp:
(JSC::Lexer<T>::shiftLineTerminator):
(JSC::LineNumberAdder::add):
LayoutTests:
* js/parse-backslash-before-newline-expected.txt:
* js/script-tests/parse-backslash-before-newline.js:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219263
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2017-07-07 Mark Lam <mark.lam@apple.com>
+
+ \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 <sbarati@apple.com>
We are missing places where we invalidate the for-in context
--- /dev/null
+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 + "'";
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) {
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);
+2017-07-07 Mark Lam <mark.lam@apple.com>
+
+ \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 <jlewis3@apple.com>
Unreviewed, rolling out r219256.
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
shouldBe('"test\\r
string with CR LF"', '"teststring with CR LF"');
-shouldBe('"test\
-\rstring with LF CR"', '"teststring with LF CR"');
+shouldThrow(`"test\
+\rstring with LF CR"`, '"SyntaxError: Unexpected EOF"');
shouldBe('"test\\rstring with CR"', '"teststring with CR"');
+2017-07-07 Mark Lam <mark.lam@apple.com>
+
+ \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 <commit-queue@webkit.org>
Unreviewed, rolling out r219238, r219239, and r219241.
/*
* Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
- * 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 (cwzwarich@uwaterloo.ca)
* Copyright (C) 2010 Zoltan Herczeg (zherczeg@inf.u-szeged.hu)
* Copyright (C) 2012 Mathias Bynens (mathias@qiwi.be)
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;
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;