fix: disallow \8, \9 in strict mode string (#11852)
This commit is contained in:
@@ -139,6 +139,7 @@ export const ErrorMessages = Object.freeze({
|
||||
StrictEvalArgumentsBinding: "Binding '%0' in strict mode",
|
||||
StrictFunction:
|
||||
"In strict mode code, functions can only be declared at top level or inside a block",
|
||||
StrictNumericEscape: "The only valid numeric escape in strict mode is '\\0'",
|
||||
StrictOctalLiteral: "Legacy octal literals are not allowed in strict mode",
|
||||
StrictWith: "'with' in strict mode",
|
||||
SuperNotAllowed:
|
||||
|
||||
@@ -1357,6 +1357,8 @@ export default class Tokenizer extends ParserErrors {
|
||||
case charCodes.digit9:
|
||||
if (inTemplate) {
|
||||
return null;
|
||||
} else if (this.state.strict) {
|
||||
this.raise(this.state.pos - 1, Errors.StrictNumericEscape);
|
||||
}
|
||||
// fall through
|
||||
default:
|
||||
@@ -1385,7 +1387,7 @@ export default class Tokenizer extends ParserErrors {
|
||||
if (inTemplate) {
|
||||
return null;
|
||||
} else if (this.state.strict) {
|
||||
this.raise(codePos, Errors.StrictOctalLiteral);
|
||||
this.raise(codePos, Errors.StrictNumericEscape);
|
||||
} else {
|
||||
// This property is used to throw an error for
|
||||
// an octal literal in a directive that occurs prior
|
||||
|
||||
Reference in New Issue
Block a user