mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-18 08:20:44 +00:00
LibRegex: Make parse_disjunction() consume all disjunctions in one frame
This helps us not blow up when too many disjunctions are chained togther in the regex we're parsing. Fixes #12615.
This commit is contained in:
parent
627bbee055
commit
4be7239626
Notes:
sideshowbarker
2024-07-17 18:29:32 +09:00
Author: https://github.com/alimpfard
Commit: 4be7239626
Pull-request: https://github.com/SerenityOS/serenity/pull/12653
Issue: https://github.com/SerenityOS/serenity/issues/12373
Issue: https://github.com/SerenityOS/serenity/issues/12615
Reviewed-by: https://github.com/trflynn89
2 changed files with 33 additions and 21 deletions
|
@ -498,6 +498,8 @@ TEST_CASE(posix_extended_nested_capture_group)
|
|||
EXPECT_EQ(result.capture_group_matches[0][2].view, "llo"sv);
|
||||
}
|
||||
|
||||
auto parse_test_case_long_disjunction_chain = String::repeated("a|"sv, 10000);
|
||||
|
||||
TEST_CASE(ECMA262_parse)
|
||||
{
|
||||
struct _test {
|
||||
|
@ -506,7 +508,7 @@ TEST_CASE(ECMA262_parse)
|
|||
regex::ECMAScriptFlags flags {};
|
||||
};
|
||||
|
||||
constexpr _test tests[] {
|
||||
_test const tests[] {
|
||||
{ "^hello.$"sv },
|
||||
{ "^(hello.)$"sv },
|
||||
{ "^h{0,1}ello.$"sv },
|
||||
|
@ -599,7 +601,8 @@ TEST_CASE(ECMA262_parse)
|
|||
{ "(?<$$_$$>a)"sv },
|
||||
{ "(?<ÿ>a)"sv },
|
||||
{ "(?<𝓑𝓻𝓸𝔀𝓷>a)"sv },
|
||||
{ "((?=lg)?[vl]k\\-?\\d{3}) bui| 3\\.[-\\w; ]{10}lg?-([06cv9]{3,4})"sv, regex::Error::NoError, ECMAScriptFlags::BrowserExtended } // #12373, quantifiable assertions.
|
||||
{ "((?=lg)?[vl]k\\-?\\d{3}) bui| 3\\.[-\\w; ]{10}lg?-([06cv9]{3,4})"sv, regex::Error::NoError, ECMAScriptFlags::BrowserExtended }, // #12373, quantifiable assertions.
|
||||
{ parse_test_case_long_disjunction_chain.view() }, // A whole lot of disjunctions, should not overflow the stack.
|
||||
};
|
||||
|
||||
for (auto& test : tests) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue