Skip to content

armgit / moli

Public Imported from GitHub
0

Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust

perf(deps): share the pinned IDNA implementation

ldm02f45fbf99057
diff --git a/Cargo.lock b/Cargo.lock
index d461cd6dd..efa39539a 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -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",
diff --git a/Cargo.toml b/Cargo.toml
index 645717335..7fdf59871 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -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" }
diff --git a/moli-cookie-store/src/cookie_domain.rs b/moli-cookie-store/src/cookie_domain.rs
index 912369e74..c32dce424 100644
--- a/moli-cookie-store/src/cookie_domain.rs
+++ b/moli-cookie-store/src/cookie_domain.rs
@@ -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<'_> {