mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
LibURL/Pattern: Fix PatternParser logic for prefix codepoint comparison
We were not properly handling the case that prefix code point was the empty string (which we represent as an OptionalNone). While this still resulted in the correct pattern string being generated, an incorrect regular expression was being generated causing matching to fail.
This commit is contained in:
parent
4b6f0ee24a
commit
0a58497ab9
Notes:
github-actions[bot]
2025-04-07 14:30:11 +00:00
Author: https://github.com/shannonbooth
Commit: 0a58497ab9
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4267
Reviewed-by: https://github.com/trflynn89 ✅
2 changed files with 4 additions and 4 deletions
|
@ -311,7 +311,7 @@ PatternErrorOr<Vector<Part>> PatternParser::parse(Utf8View const& input, Options
|
|||
prefix = char_token->value;
|
||||
|
||||
// 3. If prefix is not the empty string and not options’s prefix code point:
|
||||
if (!prefix.is_empty() && options.prefix_code_point.has_value() && prefix != String::from_code_point(*options.prefix_code_point)) {
|
||||
if (!prefix.is_empty() && (!options.prefix_code_point.has_value() || prefix != String::from_code_point(*options.prefix_code_point))) {
|
||||
// 1. Append prefix to the end of parser’s pending fixed value.
|
||||
parser.m_pending_fixed_value.append(prefix);
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@ Harness status: OK
|
|||
|
||||
Found 354 tests
|
||||
|
||||
352 Pass
|
||||
2 Fail
|
||||
353 Pass
|
||||
1 Fail
|
||||
Pass Loading data...
|
||||
Pass Pattern: [{"pathname":"/foo/bar"}] Inputs: [{"pathname":"/foo/bar"}]
|
||||
Pass Pattern: [{"pathname":"/foo/bar"}] Inputs: [{"pathname":"/foo/ba"}]
|
||||
|
@ -282,7 +282,7 @@ Pass Pattern: [{"hostname":"[*\\:1]"}] Inputs: [{"hostname":"[::ab:1]"}]
|
|||
Pass Pattern: [{"hostname":"*\\:1]"}] Inputs: undefined
|
||||
Pass Pattern: ["https://foo{{@}}example.com"] Inputs: ["https://foo@example.com"]
|
||||
Pass Pattern: ["https://foo{@example.com"] Inputs: ["https://foo@example.com"]
|
||||
Fail Pattern: ["data\\:text/javascript,let x = 100/:tens?5;"] Inputs: ["data:text/javascript,let x = 100/5;"]
|
||||
Pass Pattern: ["data\\:text/javascript,let x = 100/:tens?5;"] Inputs: ["data:text/javascript,let x = 100/5;"]
|
||||
Pass Pattern: [{"pathname":"/:id/:id"}] Inputs: undefined
|
||||
Pass Pattern: [{"pathname":"/foo","baseURL":""}] Inputs: undefined
|
||||
Pass Pattern: ["/foo",""] Inputs: undefined
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue