Disallow escape sequences in contextual keywords (#9618)
* Disallow escape sequences in async * Disallow escape sequences in get, set and async in class * invalid escape tests * Update whitelist * tests for async in parens * Add test for invalid newline between params and arrow * Move canInsertSemilcolon() into shouldPArseAsyncArrow
This commit is contained in:
@@ -1321,6 +1321,7 @@ export default class StatementParser extends ExpressionParser {
|
||||
return;
|
||||
}
|
||||
|
||||
const containsEsc = this.state.containsEsc;
|
||||
const key = this.parseClassPropertyName(member);
|
||||
const isPrivate = key.type === "PrivateName";
|
||||
// Check the key is not a computed expression or string literal.
|
||||
@@ -1371,7 +1372,12 @@ export default class StatementParser extends ExpressionParser {
|
||||
} else {
|
||||
this.pushClassProperty(classBody, publicProp);
|
||||
}
|
||||
} else if (isSimple && key.name === "async" && !this.isLineTerminator()) {
|
||||
} else if (
|
||||
isSimple &&
|
||||
key.name === "async" &&
|
||||
!containsEsc &&
|
||||
!this.isLineTerminator()
|
||||
) {
|
||||
// an async method
|
||||
const isGenerator = this.eat(tt.star);
|
||||
|
||||
@@ -1407,6 +1413,7 @@ export default class StatementParser extends ExpressionParser {
|
||||
} else if (
|
||||
isSimple &&
|
||||
(key.name === "get" || key.name === "set") &&
|
||||
!containsEsc &&
|
||||
!(this.match(tt.star) && this.isLineTerminator())
|
||||
) {
|
||||
// `get\n*` is an uninitialized property named 'get' followed by a generator.
|
||||
|
||||
Reference in New Issue
Block a user