Commit 07b958fa authored by Daniel Vogelheim's avatar Daniel Vogelheim Committed by Commit Bot

[parser] Fix parsing of escaped line terminator sequences.

R=marja@chromium.org
CC=adamk@chromium.org
Bug=v8:6401

Change-Id: Iac47c149d8c9136f4d0f5ef9844d2eaa95c2e497
Reviewed-on: https://chromium-review.googlesource.com/508696
Commit-Queue: Daniel Vogelheim <vogelheim@chromium.org>
Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45741}
parent e3801132
......@@ -983,10 +983,8 @@ bool Scanner::ScanEscape() {
// Skip escaped newlines.
if (!in_template_literal && c0_ != kEndOfInput &&
unicode_cache_->IsLineTerminator(c)) {
// Allow CR+LF newlines in multiline string literals.
// Allow escaped CR+LF newlines in multiline string literals.
if (IsCarriageReturn(c) && IsLineFeed(c0_)) Advance<capture_raw>();
// Allow LF+CR newlines in multiline string literals.
if (IsLineFeed(c) && IsCarriageReturn(c0_)) Advance<capture_raw>();
return true;
}
......
......@@ -35,10 +35,14 @@ var str = 'asdf\
';
assertEquals('asdf\nasdf\rasdf\tasdf\\', str);
// Allow CR+LF in multiline string literals.
// Allow escaped CR+LF in multiline string literals.
var code = "'asdf\\" + String.fromCharCode(0xD) + String.fromCharCode(0xA) + "asdf'";
assertEquals('asdfasdf', eval(code));
assertEquals("asdfasdf", eval(code));
// Allow LF+CR in multiline string literals.
// Allow individually escaped LF+CR in multiline string literals.
code = "'asdf\\" + String.fromCharCode(0xA) + "\\" + String.fromCharCode(0xD) + "asdf'";
assertEquals("asdfasdf", eval(code));
// Do not allow LF+CR in multiline string literals. (crbug.com/v8/6401)
code = "'asdf\\" + String.fromCharCode(0xA) + String.fromCharCode(0xD) + "asdf'";
assertEquals('asdfasdf', eval(code));
assertThrows(code);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment