Commit 4b6316c5 authored by caitpotter88's avatar caitpotter88 Committed by Commit bot

Check for octals in template spans only, not expressions

BUG=v8:3806
LOG=N
R=arv@chromium.org, dslomov@chromium.org

Review URL: https://codereview.chromium.org/808793004

Cr-Commit-Position: refs/heads/master@{#26028}
parent 0e8a6d4e
...@@ -2874,6 +2874,7 @@ ParserBase<Traits>::ParseTemplateLiteral(ExpressionT tag, int start, bool* ok) { ...@@ -2874,6 +2874,7 @@ ParserBase<Traits>::ParseTemplateLiteral(ExpressionT tag, int start, bool* ok) {
// case, representing a TemplateMiddle). // case, representing a TemplateMiddle).
do { do {
CheckTemplateOctalLiteral(pos, peek_position(), CHECK_OK);
next = peek(); next = peek();
if (!next) { if (!next) {
ReportMessageAt(Scanner::Location(start, peek_position()), ReportMessageAt(Scanner::Location(start, peek_position()),
...@@ -2897,10 +2898,10 @@ ParserBase<Traits>::ParseTemplateLiteral(ExpressionT tag, int start, bool* ok) { ...@@ -2897,10 +2898,10 @@ ParserBase<Traits>::ParseTemplateLiteral(ExpressionT tag, int start, bool* ok) {
// TEMPLATE_SPAN or TEMPLATE_TAIL. // TEMPLATE_SPAN or TEMPLATE_TAIL.
next = scanner()->ScanTemplateContinuation(); next = scanner()->ScanTemplateContinuation();
Next(); Next();
pos = position();
if (!next) { if (!next) {
ReportMessageAt(Scanner::Location(start, position()), ReportMessageAt(Scanner::Location(start, pos), "unterminated_template");
"unterminated_template");
*ok = false; *ok = false;
return Traits::EmptyExpression(); return Traits::EmptyExpression();
} }
......
...@@ -505,3 +505,16 @@ var obj = { ...@@ -505,3 +505,16 @@ var obj = {
assertEquals("\u00008", `\08`); assertEquals("\u00008", `\08`);
assertEquals("\u00009", `\09`); assertEquals("\u00009", `\09`);
})(); })();
(function testLegacyOctalEscapesInExpressions() {
// Allowed in sloppy expression
assertEquals("\x07", `${"\07"}`);
// Disallowed in template tail
assertThrows("`${\"\\07\"}\\07`", SyntaxError);
// Disallowed in strict expression
assertThrows("`${(function() { \"use strict\"; return \"\\07\"; })()}`",
SyntaxError);
})();
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