[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: Marja Hölttä <marja@chromium.org> Cr-Commit-Position: refs/heads/master@{#45741}
This commit is contained in:
parent
e38011326c
commit
07b958fae5
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user