1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:07:34 +00:00

LibRegex: Match the escaped part of escaped syntax characters

Previously, `\^` would've matched `\`, not `^`.
This commit is contained in:
AnotherTest 2021-02-26 23:21:08 +03:30 committed by Andreas Kling
parent f05e518cbc
commit 91bf3dc7fe
2 changed files with 2 additions and 1 deletions

View file

@ -1015,7 +1015,7 @@ bool ECMA262Parser::parse_atom(ByteCode& stack, size_t& match_length_minimum, bo
// Also part of AtomEscape.
auto token = consume();
match_length_minimum += 1;
stack.insert_bytecode_compare_values({ { CharacterCompareType::Char, (ByteCodeValueType)token.value()[0] } });
stack.insert_bytecode_compare_values({ { CharacterCompareType::Char, (ByteCodeValueType)token.value()[1] } });
return true;
}
if (try_skip("\\")) {

View file

@ -549,6 +549,7 @@ TEST_CASE(ECMA262_match)
{ "bar.*(?<!foo)", "barbar", true },
{ "((...)X)+", "fooXbarXbazX", true },
{ "(?:)", "", true },
{ "\\^", "^" },
// ECMA262, B.1.4. Regular Expression Pattern extensions for browsers
{ "{", "{", true, ECMAScriptFlags::BrowserExtended },
{ "\\5", "\5", true, ECMAScriptFlags::BrowserExtended },