mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 16:45:03 +00:00
LibJS: Disallow '\8' and '\9' in strict mode due to being octal escapes
This commit is contained in:
@@ -62,4 +62,11 @@ describe("octal escapes", () => {
|
||||
// Because of the non string statement in the middle strict mode is not enabled.
|
||||
expect("'\\123'; somethingElse; 'use strict'").toEval();
|
||||
});
|
||||
|
||||
test("invalid octal escapes fail in strict mode", () => {
|
||||
expect("'use strict'; '\\8'").not.toEval();
|
||||
expect("'use strict'; '\\800'").not.toEval();
|
||||
expect("'use strict'; '\\9'").not.toEval();
|
||||
expect("'use strict'; '\\912'").not.toEval();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -198,6 +198,12 @@ String Token::string_value(StringValueStatus& status) const
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lexer.next_is('8') || lexer.next_is('9')) {
|
||||
status = StringValueStatus::LegacyOctalEscapeSequence;
|
||||
builder.append(lexer.consume());
|
||||
continue;
|
||||
}
|
||||
|
||||
lexer.retreat();
|
||||
builder.append(lexer.consume_escaped_character('\\', "b\bf\fn\nr\rt\tv\v"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user