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}
This commit is contained in:
parent
0e8a6d4ec8
commit
4b6316c5ff
@ -2874,6 +2874,7 @@ ParserBase<Traits>::ParseTemplateLiteral(ExpressionT tag, int start, bool* ok) {
|
||||
// case, representing a TemplateMiddle).
|
||||
|
||||
do {
|
||||
CheckTemplateOctalLiteral(pos, peek_position(), CHECK_OK);
|
||||
next = peek();
|
||||
if (!next) {
|
||||
ReportMessageAt(Scanner::Location(start, peek_position()),
|
||||
@ -2897,10 +2898,10 @@ ParserBase<Traits>::ParseTemplateLiteral(ExpressionT tag, int start, bool* ok) {
|
||||
// TEMPLATE_SPAN or TEMPLATE_TAIL.
|
||||
next = scanner()->ScanTemplateContinuation();
|
||||
Next();
|
||||
pos = position();
|
||||
|
||||
if (!next) {
|
||||
ReportMessageAt(Scanner::Location(start, position()),
|
||||
"unterminated_template");
|
||||
ReportMessageAt(Scanner::Location(start, pos), "unterminated_template");
|
||||
*ok = false;
|
||||
return Traits::EmptyExpression();
|
||||
}
|
||||
|
@ -505,3 +505,16 @@ var obj = {
|
||||
assertEquals("\u00008", `\08`);
|
||||
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);
|
||||
})();
|
||||
|
Loading…
Reference in New Issue
Block a user