mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-28 18:47:15 +02:00
LibURL/Pattern: Ignore extra RegExp captures in match result
execResult may contain additional captures from nested groups in user-provided regexp parts, exceeding the number of URLPattern groups. Fixes a crash in the updated WPT test. See: https://github.com/whatwg/urlpattern/commit/203d435c32
This commit is contained in:
committed by
Jelle Raaijmakers
parent
e817b13c2a
commit
f4f6aefe32
Notes:
github-actions[bot]
2026-03-20 10:30:19 +00:00
Author: https://github.com/shannonbooth Commit: https://github.com/LadybirdBrowser/ladybird/commit/f4f6aefe322 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8518 Reviewed-by: https://github.com/gmta ✅
@@ -2991,5 +2991,168 @@
|
||||
"pattern": [{ "pathname": "/([\\d&&[0-1]])" }],
|
||||
"inputs": [{ "pathname": "/3" }],
|
||||
"expected_match": null
|
||||
},
|
||||
{
|
||||
"pattern": [{ "protocol": "http", "hostname": "example.com/ignoredpath" }],
|
||||
"inputs": ["http://example.com/"],
|
||||
"expected_obj": {
|
||||
"protocol": "http",
|
||||
"hostname": "example.com",
|
||||
"pathname": "*"
|
||||
},
|
||||
"expected_match": {
|
||||
"protocol": { "input": "http", "groups": {} },
|
||||
"hostname": { "input": "example.com", "groups": {} },
|
||||
"pathname": { "input": "/", "groups": { "0": "/" } }
|
||||
}
|
||||
},
|
||||
{
|
||||
"pattern": [{ "protocol": "http", "hostname": "example.com\\?ignoredsearch" }],
|
||||
"inputs": ["http://example.com/"],
|
||||
"expected_obj": {
|
||||
"protocol": "http",
|
||||
"hostname": "example.com",
|
||||
"search": "*"
|
||||
},
|
||||
"expected_match": {
|
||||
"protocol": { "input": "http", "groups": {} },
|
||||
"hostname": { "input": "example.com", "groups": {} },
|
||||
"pathname": { "input": "/", "groups": { "0": "/" } }
|
||||
}
|
||||
},
|
||||
{
|
||||
"pattern": [{ "protocol": "http", "hostname": "example.com#ignoredhash" }],
|
||||
"inputs": ["http://example.com/"],
|
||||
"expected_obj": {
|
||||
"protocol": "http",
|
||||
"hostname": "example.com",
|
||||
"hash": "*"
|
||||
},
|
||||
"expected_match": {
|
||||
"protocol": { "input": "http", "groups": {} },
|
||||
"hostname": { "input": "example.com", "groups": {} },
|
||||
"pathname": { "input": "/", "groups": { "0": "/" } }
|
||||
}
|
||||
},
|
||||
{
|
||||
"pattern": ["https://www.example.com/*"],
|
||||
"inputs": ["https://www.example.com/x"],
|
||||
"exactly_empty_components": ["port"],
|
||||
"expected_obj": {
|
||||
"protocol": "https",
|
||||
"hostname": "www.example.com",
|
||||
"pathname": "/*"
|
||||
},
|
||||
"expected_match": {
|
||||
"protocol": { "input": "https", "groups": {} },
|
||||
"hostname": { "input": "www.example.com", "groups": {} },
|
||||
"pathname": { "input": "/x", "groups": { "0": "x" } }
|
||||
}
|
||||
},
|
||||
{
|
||||
"pattern": ["https://www.example.com/*"],
|
||||
"inputs": ["https://www.example.com/xyz"],
|
||||
"exactly_empty_components": ["port"],
|
||||
"expected_obj": {
|
||||
"protocol": "https",
|
||||
"hostname": "www.example.com",
|
||||
"pathname": "/*"
|
||||
},
|
||||
"expected_match": {
|
||||
"protocol": { "input": "https", "groups": {} },
|
||||
"hostname": { "input": "www.example.com", "groups": {} },
|
||||
"pathname": { "input": "/xyz", "groups": { "0": "xyz" } }
|
||||
}
|
||||
},
|
||||
{
|
||||
"pattern": ["https://www.example.com/*"],
|
||||
"inputs": ["https://www.example.com/example"],
|
||||
"exactly_empty_components": ["port"],
|
||||
"expected_obj": {
|
||||
"protocol": "https",
|
||||
"hostname": "www.example.com",
|
||||
"pathname": "/*"
|
||||
},
|
||||
"expected_match": {
|
||||
"protocol": { "input": "https", "groups": {} },
|
||||
"hostname": { "input": "www.example.com", "groups": {} },
|
||||
"pathname": { "input": "/example", "groups": { "0": "example" } }
|
||||
}
|
||||
},
|
||||
{
|
||||
"pattern": ["https://www.example.com/*"],
|
||||
"inputs": ["https://www.example.com/text"],
|
||||
"exactly_empty_components": ["port"],
|
||||
"expected_obj": {
|
||||
"protocol": "https",
|
||||
"hostname": "www.example.com",
|
||||
"pathname": "/*"
|
||||
},
|
||||
"expected_match": {
|
||||
"protocol": { "input": "https", "groups": {} },
|
||||
"hostname": { "input": "www.example.com", "groups": {} },
|
||||
"pathname": { "input": "/text", "groups": { "0": "text" } }
|
||||
}
|
||||
},
|
||||
{
|
||||
"pattern": ["https://www.example.com/*"],
|
||||
"inputs": ["https://www.example.com/path/with/x"],
|
||||
"exactly_empty_components": ["port"],
|
||||
"expected_obj": {
|
||||
"protocol": "https",
|
||||
"hostname": "www.example.com",
|
||||
"pathname": "/*"
|
||||
},
|
||||
"expected_match": {
|
||||
"protocol": { "input": "https", "groups": {} },
|
||||
"hostname": { "input": "www.example.com", "groups": {} },
|
||||
"pathname": { "input": "/path/with/x", "groups": { "0": "path/with/x" } }
|
||||
}
|
||||
},
|
||||
{
|
||||
"pattern": [{ "hostname": ":domain(.*)" }],
|
||||
"inputs": [{ "hostname": "localhost" }],
|
||||
"expected_obj": {
|
||||
"hostname": ":domain(.*)"
|
||||
},
|
||||
"expected_match": {
|
||||
"hostname": { "input": "localhost", "groups": { "domain" : "localhost"} }
|
||||
}
|
||||
},
|
||||
{
|
||||
"pattern": ["((?R)):"],
|
||||
"expected_obj": "error"
|
||||
},
|
||||
{
|
||||
"pattern": ["(\\H):"],
|
||||
"expected_obj": "error"
|
||||
},
|
||||
{
|
||||
"pattern": [
|
||||
{"pathname": "/:foo((?<x>a))"}
|
||||
],
|
||||
"inputs": [
|
||||
{"pathname": "/a"}
|
||||
],
|
||||
"expected_match": {
|
||||
"pathname": {
|
||||
"input": "/a",
|
||||
"groups": {"foo": "a"}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"pattern": [
|
||||
{"pathname": "/foo/(bar(?<x>baz))"}
|
||||
],
|
||||
"inputs": [
|
||||
{"pathname": "/foo/barbaz"}
|
||||
],
|
||||
"expected_match": {
|
||||
"pathname": {
|
||||
"input": "/foo/barbaz",
|
||||
"groups": {"0": "barbaz"}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user