mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:37:35 +00:00
Revert "LibRegex: Implement an ECMA262 Regex quirk with negative loo..."
This partially reverts commit c11be92e23
.
That commit fixes one thing and breaks many more, a next commit will
implement this quirk in a more sane way.
This commit is contained in:
parent
e0d3a8f6ce
commit
704e0654b3
2 changed files with 2 additions and 14 deletions
|
@ -682,7 +682,6 @@ TEST_CASE(ECMA262_match)
|
||||||
{ "[\\0]"sv, "\0"sv, true, combine_flags(ECMAScriptFlags::Unicode, ECMAScriptFlags::BrowserExtended) },
|
{ "[\\0]"sv, "\0"sv, true, combine_flags(ECMAScriptFlags::Unicode, ECMAScriptFlags::BrowserExtended) },
|
||||||
{ "[\\01]"sv, "\1"sv, true, ECMAScriptFlags::BrowserExtended },
|
{ "[\\01]"sv, "\1"sv, true, ECMAScriptFlags::BrowserExtended },
|
||||||
{ "(\0|a)"sv, "a"sv, true }, // #9686, Should allow null bytes in pattern
|
{ "(\0|a)"sv, "a"sv, true }, // #9686, Should allow null bytes in pattern
|
||||||
{ "(.*?)a(?!(a+)b\\2c)\\2(.*)"sv, "baaabaac"sv, true }, // #6042, Groups inside lookarounds may be referenced outside, but their contents appear empty if the pattern in the lookaround fails.
|
|
||||||
{ "a|$"sv, "x"sv, true, (ECMAScriptFlags)regex::AllFlags::Global }, // #11940, Global (not the 'g' flag) regexps should attempt to match the zero-length end of the string too.
|
{ "a|$"sv, "x"sv, true, (ECMAScriptFlags)regex::AllFlags::Global }, // #11940, Global (not the 'g' flag) regexps should attempt to match the zero-length end of the string too.
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
|
@ -489,14 +489,7 @@ Optional<bool> Matcher<Parser>::execute(MatchInput const& input, MatchState& sta
|
||||||
return true;
|
return true;
|
||||||
case ExecutionResult::Failed:
|
case ExecutionResult::Failed:
|
||||||
if (!states_to_try_next.is_empty()) {
|
if (!states_to_try_next.is_empty()) {
|
||||||
auto next_state = states_to_try_next.take_last();
|
state = states_to_try_next.take_last();
|
||||||
// Note: ECMA262 quirk: Note 3, https://tc39.es/ecma262/#sec-runtime-semantics-canonicalize-ch
|
|
||||||
// capture groups defined in lookarounds "leak" outside the regex,
|
|
||||||
// but their contents are empty if the lookaround fails.
|
|
||||||
// This is done by manually clearing the groups where needed, and leaking their contents here.
|
|
||||||
if constexpr (IsSame<Parser, ECMA262>)
|
|
||||||
swap(next_state.capture_group_matches, state.capture_group_matches);
|
|
||||||
state = move(next_state);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -506,11 +499,7 @@ Optional<bool> Matcher<Parser>::execute(MatchInput const& input, MatchState& sta
|
||||||
return {};
|
return {};
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
auto next_state = states_to_try_next.take_last();
|
state = states_to_try_next.take_last();
|
||||||
// See note above about an ECMA262 quirk.
|
|
||||||
if constexpr (IsSame<Parser, ECMA262>)
|
|
||||||
swap(next_state.capture_group_matches, state.capture_group_matches);
|
|
||||||
state = move(next_state);
|
|
||||||
++recursion_level;
|
++recursion_level;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue