diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2022-01-21 14:50:30 +0330 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2022-01-21 18:14:08 +0330 |
commit | 9eccd4c56e09fb5b7a08e4288d174f5a27c75695 (patch) | |
tree | 2aa3c0454e3737a4b7cd85cbbd023b416dee51a9 /Userland/Libraries/LibRegex | |
parent | c11be92e23d899e28d45f67be24e47b2e5114d3a (diff) | |
download | serenity-9eccd4c56e09fb5b7a08e4288d174f5a27c75695.zip |
LibRegex: Allow the pattern to match the zero-length end of the string
...only if Multiline is not enabled.
Fixes #11940.
Diffstat (limited to 'Userland/Libraries/LibRegex')
-rw-r--r-- | Userland/Libraries/LibRegex/RegexMatcher.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Userland/Libraries/LibRegex/RegexMatcher.cpp b/Userland/Libraries/LibRegex/RegexMatcher.cpp index 26ae07d886..18da4dd370 100644 --- a/Userland/Libraries/LibRegex/RegexMatcher.cpp +++ b/Userland/Libraries/LibRegex/RegexMatcher.cpp @@ -224,7 +224,10 @@ RegexResult Matcher<Parser>::match(Vector<RegexStringView> const& views, Optiona } } - for (; view_index < view_length; ++view_index) { + for (; view_index <= view_length; ++view_index) { + if (view_index == view_length && input.regex_options.has_flag_set(AllFlags::Multiline)) + break; + auto& match_length_minimum = m_pattern->parser_result.match_length_minimum; // FIXME: More performant would be to know the remaining minimum string // length needed to match from the current position onwards within |