Bug 173053

Summary: \n\r is not the same as \r\n
Product: WebKit Reporter: Peter van der Zee <webkit>
Component: JavaScriptCoreAssignee: Mark Lam <mark.lam>
Status: RESOLVED FIXED    
Severity: Normal CC: buildbot, fpizlo, keith_miller, mark.lam, mathias, msaboff, rniwa, saam, ysuzuki
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 170810    
Attachments:
Description Flags
proposed patch.
buildbot: commit-queue-
Archive of layout-test-results from ews102 for mac-elcapitan
none
Archive of layout-test-results from ews106 for mac-elcapitan-wk2
none
Archive of layout-test-results from ews117 for mac-elcapitan
none
Archive of layout-test-results from ews121 for ios-simulator-wk2
none
proposed patch w/ updated test baselines.
none
proposed patch. keith_miller: review+

Peter van der Zee
Reported 2017-06-07 04:34:56 PDT
What steps will reproduce the problem? 1. eval("'\\\n\r'") What is the expected output? Uncaught SyntaxError: Invalid or unexpected token What do you see instead? A parser bug! :) Description: The spec explicitly treats `\r\n` as a single newline token rather than two but individual `\n` and `\r` characters cause individual newline tokens. When back-to-back `\n\r` causes two tokens. This is normally not very relevant, only to the point of line number reporting, but there's an edge case concerning so called "newline escapes" in single/double strings; Escaping a newline there takes this distinction into account and `'\\\r\n'` should be fine while `'\\\n\r'` should trigger an error on an unescaped `\r`. See also https://bugs.chromium.org/p/v8/issues/detail?id=6401
Attachments
proposed patch. (3.01 KB, patch)
2017-06-07 13:04 PDT, Mark Lam
buildbot: commit-queue-
Archive of layout-test-results from ews102 for mac-elcapitan (998.07 KB, application/zip)
2017-06-07 14:03 PDT, Build Bot
no flags
Archive of layout-test-results from ews106 for mac-elcapitan-wk2 (1.07 MB, application/zip)
2017-06-07 14:10 PDT, Build Bot
no flags
Archive of layout-test-results from ews117 for mac-elcapitan (1.74 MB, application/zip)
2017-06-07 14:22 PDT, Build Bot
no flags
Archive of layout-test-results from ews121 for ios-simulator-wk2 (6.90 MB, application/zip)
2017-06-07 14:32 PDT, Build Bot
no flags
proposed patch w/ updated test baselines. (6.46 KB, patch)
2017-06-10 08:06 PDT, Mark Lam
no flags
proposed patch. (6.72 KB, patch)
2017-07-07 12:29 PDT, Mark Lam
keith_miller: review+
Peter van der Zee
Comment 1 2017-06-07 04:36:14 PDT
r/newline escapes/line continuations
Mark Lam
Comment 2 2017-06-07 11:19:23 PDT
Seems like a simple thing to fix. I'll take a look.
Mark Lam
Comment 3 2017-06-07 13:04:39 PDT
Created attachment 312213 [details] proposed patch. Let's try this on the EWS first.
Build Bot
Comment 4 2017-06-07 13:44:41 PDT
Comment on attachment 312213 [details] proposed patch. Attachment 312213 [details] did not pass jsc-ews (mac): Output: http://webkit-queues.webkit.org/results/3889531 New failing tests: stress/template-literal-line-terminators.js.ftl-eager stress/template-literal-line-terminators.js.no-cjit-validate-phases jsc-layout-tests.yaml/js/script-tests/parse-backslash-before-newline.js.layout-dfg-eager-no-cjit stress/template-literal-line-terminators.js.ftl-no-cjit-no-inline-validate stress/template-literal-line-terminators.js.ftl-eager-no-cjit stress/template-literal-line-terminators.js.ftl-no-cjit-b3o1 stress/template-literal-line-terminators.js.default jsc-layout-tests.yaml/js/script-tests/parse-backslash-before-newline.js.layout-ftl-no-cjit stress/template-literal-line-terminators.js.no-cjit-collect-continuously stress/template-literal-line-terminators.js.ftl-eager-no-cjit-b3o1 stress/template-literal-line-terminators.js.ftl-no-cjit-no-put-stack-validate jsc-layout-tests.yaml/js/script-tests/parse-backslash-before-newline.js.layout-no-ftl stress/template-literal-line-terminators.js.dfg-eager-no-cjit-validate jsc-layout-tests.yaml/js/script-tests/parse-backslash-before-newline.js.layout-ftl-eager-no-cjit stress/template-literal-line-terminators.js.no-llint stress/template-literal-line-terminators.js.ftl-no-cjit-validate-sampling-profiler stress/template-literal-line-terminators.js.dfg-maximal-flush-validate-no-cjit jsc-layout-tests.yaml/js/script-tests/parse-backslash-before-newline.js.layout-no-cjit jsc-layout-tests.yaml/js/script-tests/parse-backslash-before-newline.js.layout jsc-layout-tests.yaml/js/script-tests/parse-backslash-before-newline.js.layout-no-llint stress/template-literal-line-terminators.js.no-ftl stress/template-literal-line-terminators.js.dfg-eager stress/template-literal-line-terminators.js.ftl-no-cjit-small-pool
Build Bot
Comment 5 2017-06-07 14:03:28 PDT
Comment on attachment 312213 [details] proposed patch. Attachment 312213 [details] did not pass mac-ews (mac): Output: http://webkit-queues.webkit.org/results/3889656 New failing tests: js/parse-backslash-before-newline.html
Build Bot
Comment 6 2017-06-07 14:03:29 PDT
Created attachment 312222 [details] Archive of layout-test-results from ews102 for mac-elcapitan The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews102 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Build Bot
Comment 7 2017-06-07 14:10:11 PDT
Comment on attachment 312213 [details] proposed patch. Attachment 312213 [details] did not pass mac-wk2-ews (mac-wk2): Output: http://webkit-queues.webkit.org/results/3889688 New failing tests: js/parse-backslash-before-newline.html
Build Bot
Comment 8 2017-06-07 14:10:13 PDT
Created attachment 312223 [details] Archive of layout-test-results from ews106 for mac-elcapitan-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews106 Port: mac-elcapitan-wk2 Platform: Mac OS X 10.11.6
Build Bot
Comment 9 2017-06-07 14:22:56 PDT
Comment on attachment 312213 [details] proposed patch. Attachment 312213 [details] did not pass mac-debug-ews (mac): Output: http://webkit-queues.webkit.org/results/3889691 New failing tests: js/parse-backslash-before-newline.html
Build Bot
Comment 10 2017-06-07 14:22:58 PDT
Created attachment 312226 [details] Archive of layout-test-results from ews117 for mac-elcapitan The attached test failures were seen while running run-webkit-tests on the mac-debug-ews. Bot: ews117 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Build Bot
Comment 11 2017-06-07 14:32:54 PDT
Comment on attachment 312213 [details] proposed patch. Attachment 312213 [details] did not pass ios-sim-ews (ios-simulator-wk2): Output: http://webkit-queues.webkit.org/results/3889701 New failing tests: js/parse-backslash-before-newline.html
Build Bot
Comment 12 2017-06-07 14:32:55 PDT
Created attachment 312229 [details] Archive of layout-test-results from ews121 for ios-simulator-wk2 The attached test failures were seen while running run-webkit-tests on the ios-sim-ews. Bot: ews121 Port: ios-simulator-wk2 Platform: Mac OS X 10.12.5
Mark Lam
Comment 13 2017-06-10 08:06:08 PDT
Created attachment 312570 [details] proposed patch w/ updated test baselines.
Mark Lam
Comment 14 2017-06-10 08:58:21 PDT
Comment on attachment 312570 [details] proposed patch w/ updated test baselines. The patch applies properly: I tested applying it locally on another checkout. The EWS patching system just does not like the \r in the patch. Unfortunately, the nature of this fix is in the handling of \n\r. So, I can't remove the use of \r in the test case. Let's get the patch reviewed.
Yusuke Suzuki
Comment 15 2017-06-10 10:20:48 PDT
Comment on attachment 312570 [details] proposed patch w/ updated test baselines. View in context: https://bugs.webkit.org/attachment.cgi?id=312570&action=review > Source/JavaScriptCore/parser/Lexer.cpp:708 > // Allow both CRLF and LFCR. Let's change this comment. > Source/JavaScriptCore/parser/Lexer.cpp:1416 > ++m_lineNumber; I think now this LineNumberAdder is not necessary. This is added to increnting one line number with <LF><CR> while normalizing them as <LF><LF>. However, now, our Lexer does not accept `<LF><CR>` as one line terminator. Thus, I think we can discard this class!
Mark Lam
Comment 16 2017-06-10 10:49:12 PDT
(In reply to Yusuke Suzuki from comment #15) > Comment on attachment 312570 [details] > proposed patch w/ updated test baselines. > > View in context: > https://bugs.webkit.org/attachment.cgi?id=312570&action=review > > > Source/JavaScriptCore/parser/Lexer.cpp:708 > > // Allow both CRLF and LFCR. > > Let's change this comment. I deleted the comment. I think the code now says what is allowed clearly enough. > > Source/JavaScriptCore/parser/Lexer.cpp:1416 > > ++m_lineNumber; > > I think now this LineNumberAdder is not necessary. This is added to > increnting one line number with <LF><CR> while normalizing them as <LF><LF>. > However, now, our Lexer does not accept `<LF><CR>` as one line terminator. > Thus, I think we can discard this class! Thanks. Fixed.
Yusuke Suzuki
Comment 17 2017-07-06 02:16:24 PDT
How about this patch?
Mark Lam
Comment 18 2017-07-06 15:01:03 PDT
(In reply to Yusuke Suzuki from comment #17) > How about this patch? I'm still working thru some test failures. This is a low priority task for me, but I'm trying to wrap it up.
Mark Lam
Comment 19 2017-07-07 12:29:08 PDT
Created attachment 314859 [details] proposed patch. This patch has passed the JSC and layout tests on my local runs.
Keith Miller
Comment 20 2017-07-07 12:43:52 PDT
Comment on attachment 314859 [details] proposed patch. r=me.
Mark Lam
Comment 21 2017-07-07 12:51:30 PDT
Thanks for the review. Landed in r219263: <http://trac.webkit.org/r219263>.
Note You need to log in before you can comment on or make changes to this bug.