mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 13:49:16 +00:00
LibRegex: Treat the UnicodeSets flag as Unicode
Fixes /.../v not being interpreted as a unicode pattern.
This commit is contained in:
parent
14ebcd4881
commit
ea3b7efd91
Notes:
github-actions[bot]
2025-02-28 19:32:42 +00:00
Author: https://github.com/alimpfard
Commit: ea3b7efd91
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3730
3 changed files with 7 additions and 2 deletions
|
@ -72,3 +72,8 @@ test("regexp that always matches stops matching if it's past the end of the stri
|
||||||
expect("whf".match(re)).toEqual(["", "", "", ""]);
|
expect("whf".match(re)).toEqual(["", "", "", ""]);
|
||||||
expect(re.lastIndex).toBe(0);
|
expect(re.lastIndex).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("v flag should enable unicode mode", () => {
|
||||||
|
const re = new RegExp("a\\u{10FFFF}", "v");
|
||||||
|
expect(re.test("a\u{10FFFF}")).toBe(true);
|
||||||
|
});
|
||||||
|
|
|
@ -160,7 +160,7 @@ RegexResult Matcher<Parser>::match(Vector<RegexStringView> const& views, Optiona
|
||||||
input.start_offset = m_pattern->start_offset;
|
input.start_offset = m_pattern->start_offset;
|
||||||
size_t lines_to_skip = 0;
|
size_t lines_to_skip = 0;
|
||||||
|
|
||||||
bool unicode = input.regex_options.has_flag_set(AllFlags::Unicode);
|
bool unicode = input.regex_options.has_flag_set(AllFlags::Unicode) || input.regex_options.has_flag_set(AllFlags::UnicodeSets);
|
||||||
for (auto const& view : views)
|
for (auto const& view : views)
|
||||||
const_cast<RegexStringView&>(view).set_unicode(unicode);
|
const_cast<RegexStringView&>(view).set_unicode(unicode);
|
||||||
|
|
||||||
|
|
|
@ -627,7 +627,7 @@ bool Regex<Parser>::attempt_rewrite_entire_match_as_substring_search(BasicBlockL
|
||||||
|
|
||||||
auto& bytecode = parser_result.bytecode;
|
auto& bytecode = parser_result.bytecode;
|
||||||
|
|
||||||
auto is_unicode = parser_result.options.has_flag_set(AllFlags::Unicode);
|
auto is_unicode = parser_result.options.has_flag_set(AllFlags::Unicode) || parser_result.options.has_flag_set(AllFlags::UnicodeSets);
|
||||||
|
|
||||||
// We have a single basic block, let's see if it's a series of character or string compares.
|
// We have a single basic block, let's see if it's a series of character or string compares.
|
||||||
StringBuilder final_string;
|
StringBuilder final_string;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue