diff options
-rw-r--r-- | Libraries/LibRegex/RegexParser.cpp | 5 | ||||
-rw-r--r-- | Libraries/LibRegex/Tests/Regex.cpp | 1 |
2 files changed, 6 insertions, 0 deletions
diff --git a/Libraries/LibRegex/RegexParser.cpp b/Libraries/LibRegex/RegexParser.cpp index 6015212123..2afbad64c7 100644 --- a/Libraries/LibRegex/RegexParser.cpp +++ b/Libraries/LibRegex/RegexParser.cpp @@ -741,6 +741,11 @@ bool ECMA262Parser::parse_assertion(ByteCode& stack, [[maybe_unused]] size_t& ma if (!try_skip("(?")) return false; + if (done()) { + set_error(Error::InvalidCaptureGroup); + return false; + } + ByteCode assertion_stack; size_t length_dummy = 0; diff --git a/Libraries/LibRegex/Tests/Regex.cpp b/Libraries/LibRegex/Tests/Regex.cpp index e4fb05c3c4..0bb2e8d2ef 100644 --- a/Libraries/LibRegex/Tests/Regex.cpp +++ b/Libraries/LibRegex/Tests/Regex.cpp @@ -500,6 +500,7 @@ TEST_CASE(ECMA262_parse) { "(?", regex::Error::InvalidCaptureGroup }, { "\\u1234", regex::Error::NoError, regex::ECMAScriptFlags::Unicode }, { "[\\u1234]", regex::Error::NoError, regex::ECMAScriptFlags::Unicode }, + { ",(?", regex::Error::InvalidCaptureGroup }, // #4583 }; for (auto& test : tests) { |