perf(deps): share the pinned IDNA implementation

Resolve cookie and URL IDNA consumers to the pinned rust-url revision,
removing the duplicate registry implementation. Cover Unicode cookie
domains, canonical URLs and host-only matching.

Validation on the unchanged final source tree: cargo fmt --all;
cargo clippy --workspace --all-targets --all-features -- -D warnings;
cargo nextest run --no-fail-fast (20,505 passed, 18 existing skips).
This commit is contained in:
ldm0
2026-10-21 23:16:23 +08:00
committed by Donough Liu
parent 2b6f116c5a
commit 2f45fbf990
3 changed files with 31 additions and 13 deletions
Generated
+2 -13
View File
@@ -2109,17 +2109,6 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
[[package]]
name = "idna"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de"
dependencies = [
"idna_adapter",
"smallvec",
"utf8_iter",
]
[[package]]
name = "idna"
version = "1.1.0"
@@ -2750,7 +2739,7 @@ version = "0.22.1"
dependencies = [
"cookie",
"document-features",
"idna 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"idna",
"indexmap",
"psl-types",
"time",
@@ -6266,7 +6255,7 @@ version = "2.5.8"
source = "git+https://github.com/lexmount/rust-url?rev=ca9fcad2b99f20c30c28a618ad78410f6fd31161#ca9fcad2b99f20c30c28a618ad78410f6fd31161"
dependencies = [
"form_urlencoded 1.2.2 (git+https://github.com/lexmount/rust-url?rev=ca9fcad2b99f20c30c28a618ad78410f6fd31161)",
"idna 1.1.0 (git+https://github.com/lexmount/rust-url?rev=ca9fcad2b99f20c30c28a618ad78410f6fd31161)",
"idna",
"percent-encoding 2.3.2 (git+https://github.com/lexmount/rust-url?rev=ca9fcad2b99f20c30c28a618ad78410f6fd31161)",
"serde",
"serde_derive",
+1
View File
@@ -103,6 +103,7 @@ fontique = { git = "https://github.com/lexmount/parley", rev = "a18cfc3ba6638d44
# Share fontations between shaping, raster rendering and PDF font subsetting.
subsetter = { git = "https://github.com/lexmount/subsetter", rev = "8d3815245835af309559c3b4a872d6a0a54913a9" }
url = { git = "https://github.com/lexmount/rust-url", rev = "ca9fcad2b99f20c30c28a618ad78410f6fd31161" }
idna = { git = "https://github.com/lexmount/rust-url", rev = "ca9fcad2b99f20c30c28a618ad78410f6fd31161" }
xml5ever = { git = "https://github.com/lexmount/html5ever", rev = "4574311c63e79bba7d4ddb98cb0562d8dad499ee" }
curl = { git = "https://github.com/lexmount/curl-rust", rev = "79310cbd939be3548b78d0b23ab1d60d5facdeec" }
curl-sys = { git = "https://github.com/lexmount/curl-rust", rev = "79310cbd939be3548b78d0b23ab1d60d5facdeec" }
+28
View File
@@ -297,6 +297,34 @@ mod tests {
);
}
#[test]
fn unicode_cookie_domains_match_canonical_ascii_urls() {
let expected = CookieDomain::Suffix(String::from("xn--bcher-kva.example"));
let parsed = CookieDomain::try_from(".bücher.example")
.expect("Unicode cookie domain should be canonicalized");
assert_eq!(parsed, expected);
matches(true, &parsed, "https://bücher.example/");
matches(true, &parsed, "https://xn--bcher-kva.example/");
matches(true, &parsed, "https://sub.xn--bcher-kva.example/");
matches(false, &parsed, "https://other.example/");
let raw =
RawCookie::parse("idna=1; Domain=.bücher.example").expect("raw Unicode domain cookie");
let from_raw = CookieDomain::try_from(&raw)
.expect("raw Unicode cookie domain should be canonicalized");
assert_eq!(from_raw, expected);
matches(true, &from_raw, "https://xn--bcher-kva.example/");
let request = Url::parse("https://bücher.example/").expect("Unicode request URL");
let host_only = CookieDomain::host_only(&request).expect("Unicode host-only cookie");
assert_eq!(
host_only,
CookieDomain::HostOnly(String::from("xn--bcher-kva.example"))
);
matches(true, &host_only, "https://xn--bcher-kva.example/");
matches(false, &host_only, "https://sub.xn--bcher-kva.example/");
}
#[test]
fn from_raw_cookie() {
fn raw_cookie(s: &str) -> RawCookie<'_> {