Changeset 219263 in webkit


Ignore:
Timestamp:
Jul 7, 2017 12:50:00 PM (7 years ago)
Author:
mark.lam@apple.com
Message:

\n\r is not the same as \r\n.
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:
Location:
trunk
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r219209 r219263  
     12017-07-07  Mark Lam  <mark.lam@apple.com>
     2
     3        \n\r is not the same as \r\n.
     4        https://bugs.webkit.org/show_bug.cgi?id=173053
     5
     6        Reviewed by Keith Miller.
     7
     8        * stress/regress-173053.js: Added.
     9        * stress/template-literal-line-terminators.js:
     10
    1112017-07-06  Saam Barati  <sbarati@apple.com>
    212
  • trunk/JSTests/stress/template-literal-line-terminators.js

    r183559 r219263  
    22function test(actual, expected) {
    33    if (actual !== expected)
    4         throw new Error("bad value: " + actual);
     4        throw new Error("bad value: actual: " + actual + ", expected: " + expected);
    55}
    66
     
    3737testEvalLineNumber("`Hello\r\nWorld`", "Hello\nWorld", 2);
    3838testEvalLineNumber("`Hello\n\nWorld`", "Hello\n\nWorld", 3);
    39 testEvalLineNumber("`Hello\n\rWorld`", "Hello\n\nWorld", 2);
     39testEvalLineNumber("`Hello\n\rWorld`", "Hello\n\nWorld", 3);
    4040
    4141testEvalLineNumber("`Hello\n\r\nWorld`", "Hello\n\nWorld", 3);
     
    4343testEvalLineNumber("`Hello\n\n\nWorld`", "Hello\n\n\nWorld", 4);
    4444
    45 testEvalLineNumber("`Hello\n\r\n\rWorld`", "Hello\n\n\nWorld", 3);
     45testEvalLineNumber("`Hello\n\r\n\rWorld`", "Hello\n\n\nWorld", 4);
    4646testEvalLineNumber("`Hello\n\r\n\nWorld`", "Hello\n\n\nWorld", 4);
    4747testEvalLineNumber("`Hello\r\n\n\nWorld`", "Hello\n\n\nWorld", 4);
    4848
    49 testEvalLineNumber("`Hello\\\n\r\rWorld`", "Hello\n\nWorld", 3);
     49testEvalLineNumber("`Hello\\\n\r\rWorld`", "Hello\n\nWorld", 4);
    5050testEvalLineNumber("`Hello\\\r\n\n\nWorld`", "Hello\n\nWorld", 4);
    5151testEvalLineNumber("`Hello\\\n\r\n\nWorld`", "Hello\n\nWorld", 4);
    52 testEvalLineNumber("`Hello\\\n\r\r\nWorld`", "Hello\n\nWorld", 3);
     52testEvalLineNumber("`Hello\\\n\r\r\nWorld`", "Hello\n\nWorld", 4);
    5353
    5454testEvalLineNumber("`\u2028`", "\u2028", 2);
  • trunk/LayoutTests/ChangeLog

    r219262 r219263  
     12017-07-07  Mark Lam  <mark.lam@apple.com>
     2
     3        \n\r is not the same as \r\n.
     4        https://bugs.webkit.org/show_bug.cgi?id=173053
     5
     6        Reviewed by Keith Miller.
     7
     8        * js/parse-backslash-before-newline-expected.txt:
     9        * js/script-tests/parse-backslash-before-newline.js:
     10
    1112017-07-07  Matt Lewis  <jlewis3@apple.com>
    212
  • trunk/LayoutTests/js/parse-backslash-before-newline-expected.txt

    r12262 r219263  
    11PASS "teststring with CR LF" is "teststring with CR LF"
    2 PASS "teststring with LF CR" is "teststring with LF CR"
     2PASS "test
     3string with LF CR" threw exception SyntaxError: Unexpected EOF.
    34PASS "teststring with CR" is "teststring with CR"
    45PASS "teststring with LF" is "teststring with LF"
  • trunk/LayoutTests/js/script-tests/parse-backslash-before-newline.js

    r98407 r219263  
    22string with CR LF"', '"teststring with CR LF"');
    33
    4 shouldBe('"test\
     4shouldThrow(`"test\
    55
    6 string with LF CR"', '"teststring with LF CR"');
     6string with LF CR"`, '"SyntaxError: Unexpected EOF"');
    77
    88shouldBe('"test\
  • trunk/Source/JavaScriptCore/ChangeLog

    r219260 r219263  
     12017-07-07  Mark Lam  <mark.lam@apple.com>
     2
     3        \n\r is not the same as \r\n.
     4        https://bugs.webkit.org/show_bug.cgi?id=173053
     5
     6        Reviewed by Keith Miller.
     7
     8        * parser/Lexer.cpp:
     9        (JSC::Lexer<T>::shiftLineTerminator):
     10        (JSC::LineNumberAdder::add):
     11
    1122017-07-07  Commit Queue  <commit-queue@webkit.org>
    213
  • trunk/Source/JavaScriptCore/parser/Lexer.cpp

    r218819 r219263  
    11/*
    22 *  Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
    3  *  Copyright (C) 2006-2009, 2011-2013, 2016 Apple Inc. All Rights Reserved.
     3 *  Copyright (C) 2006-2017 Apple Inc. All Rights Reserved.
    44 *  Copyright (C) 2007 Cameron Zwarich (cwzwarich@uwaterloo.ca)
    55 *  Copyright (C) 2010 Zoltan Herczeg (zherczeg@inf.u-szeged.hu)
     
    706706    shift();
    707707
    708     // Allow both CRLF and LFCR.
    709     if (prev + m_current == '\n' + '\r')
     708    if (prev == '\r' && m_current == '\n')
    710709        shift();
    711710
     
    14121411    {
    14131412        ASSERT(Lexer<CharacterType>::isLineTerminator(character));
    1414         if ((character + m_previous) == ('\n' + '\r'))
     1413        if (m_previous == '\r' && character == '\n')
    14151414            m_previous = 0;
    14161415        else {
Note: See TracChangeset for help on using the changeset viewer.