mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-31 12:54:11 +00:00
LibRegex: Correctly advance string positions in Compare::compare_string
Fixes a bug where backreferences could cause desync between the code point index and regular index, making comparison off-by-N.
This commit is contained in:
committed by
Andreas Kling
parent
dd82c2e9b4
commit
9b2f0613ef
@@ -102,6 +102,12 @@ static void advance_string_position(MatchState& state, RegexStringView const& vi
|
||||
}
|
||||
}
|
||||
|
||||
static void advance_string_position(MatchState& state, RegexStringView const&, RegexStringView const& advance_by)
|
||||
{
|
||||
state.string_position += advance_by.length();
|
||||
state.string_position_in_code_units += advance_by.length_in_code_units();
|
||||
}
|
||||
|
||||
static void reverse_string_position(MatchState& state, RegexStringView const& view, size_t amount)
|
||||
{
|
||||
VERIFY(state.string_position >= amount);
|
||||
@@ -606,7 +612,7 @@ ALWAYS_INLINE bool OpCode_Compare::compare_string(MatchInput const& input, Match
|
||||
equals = subject.equals(str);
|
||||
|
||||
if (equals)
|
||||
state.string_position += str.length();
|
||||
advance_string_position(state, input.view, str);
|
||||
|
||||
return equals;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user