diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:11:38 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:13:23 +0000 |
commit | 20431706a863f92cb37dc512fef6e48d192aaf2c (patch) | |
tree | 2867f13f5fd5437ba628c67d7f87309ccadcd286 /vendor/idna | |
parent | Releasing progress-linux version 1.65.0+dfsg1-2~progress7.99u1. (diff) | |
download | rustc-20431706a863f92cb37dc512fef6e48d192aaf2c.tar.xz rustc-20431706a863f92cb37dc512fef6e48d192aaf2c.zip |
Merging upstream version 1.66.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/idna')
-rw-r--r-- | vendor/idna/.cargo-checksum.json | 2 | ||||
-rw-r--r-- | vendor/idna/Cargo.toml | 23 | ||||
-rw-r--r-- | vendor/idna/LICENSE-MIT | 2 | ||||
-rw-r--r-- | vendor/idna/src/lib.rs | 3 | ||||
-rw-r--r-- | vendor/idna/src/uts46.rs | 76 | ||||
-rw-r--r-- | vendor/idna/tests/punycode.rs | 4 | ||||
-rw-r--r-- | vendor/idna/tests/tests.rs | 12 | ||||
-rw-r--r-- | vendor/idna/tests/uts46.rs | 13 |
8 files changed, 76 insertions, 59 deletions
diff --git a/vendor/idna/.cargo-checksum.json b/vendor/idna/.cargo-checksum.json index 01c1655f1..edf5c94ba 100644 --- a/vendor/idna/.cargo-checksum.json +++ b/vendor/idna/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"fa141dcb135262e5fda9f680671699045326d96779bb1acf38d48c70c712bcdf","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"20c7855c364d57ea4c97889a5e8d98470a9952dade37bd9248b9a54431670e5e","benches/all.rs":"e734b9c9092ed66986725f86cfe90f3756cfddb058af308b796ba494f9beefc2","src/IdnaMappingTable.txt":"87d6553a4b86bc49dcade38bf26b745cd81800eb8af295dc3fb99b4729eaea38","src/lib.rs":"d61b2bfcf4265b9a41eedd1de33ab49ea615e3c06df944321b30c57950a85342","src/make_uts46_mapping_table.py":"917055fa841f813de2bcf79cc79b595da3d5551559ee768db8660ab77cb26c34","src/punycode.rs":"07edf5293bc384a164eebb01bc18fe3d4b2d009b4565a36b74a3030978ea6e04","src/uts46.rs":"40521a01e5b8c38667252d5b1e0141c5a71f63aeae2f451b986792984e633b09","src/uts46_mapping_table.rs":"942fff78147c61da942f5f3a7ff4e90f9d7a00a29285733ac3fc3357eb2ed06f","tests/IdnaTestV2.txt":"c6f3778b0545fd150c8063286c7f5adc901e16557eddccc3751213646d07593d","tests/punycode.rs":"e6fb978f48445d1525a6b97351c41c5393a1612a35f85b9a7f45b8794fce9aba","tests/punycode_tests.json":"3d4ac0cf25984c37b9ce197f5df680a0136f728fb8ec82bc76624e42139eb3a8","tests/tests.rs":"de7425a3e4e6e871255721107803704d1431246601fa9c87105224d88dfe60d6","tests/unit.rs":"be025a7d9bab3bd1ce134c87f9d848269e157b31ca5ba0ea03426c1ac736b69e","tests/uts46.rs":"ca91d48811d366fb9e32d7aa79cfda1261b93c271b6ed7fb5535de9a2500205b"},"package":"418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8"}
\ No newline at end of file +{"files":{"Cargo.toml":"e8c4cbd1a352ce9085b80ac9fcaa8468a2da84b615adf01e719a3020a0279e4c","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"76e972ac0f4ddb116e86e10100132a783931a596e7b9872eaa31be15cd4d751d","benches/all.rs":"e734b9c9092ed66986725f86cfe90f3756cfddb058af308b796ba494f9beefc2","src/IdnaMappingTable.txt":"87d6553a4b86bc49dcade38bf26b745cd81800eb8af295dc3fb99b4729eaea38","src/lib.rs":"498f127759fa79bda0d264f373ab7230cc2c73ef3a7b532d619c2a513abb53ff","src/make_uts46_mapping_table.py":"917055fa841f813de2bcf79cc79b595da3d5551559ee768db8660ab77cb26c34","src/punycode.rs":"07edf5293bc384a164eebb01bc18fe3d4b2d009b4565a36b74a3030978ea6e04","src/uts46.rs":"1a5604c32cf57b50e846b58aaaba94e685ff10975e9d6d82ae953f8cefe9c028","src/uts46_mapping_table.rs":"942fff78147c61da942f5f3a7ff4e90f9d7a00a29285733ac3fc3357eb2ed06f","tests/IdnaTestV2.txt":"c6f3778b0545fd150c8063286c7f5adc901e16557eddccc3751213646d07593d","tests/punycode.rs":"7eb6215fa4c84e6710682d48dffe19e490aea223b554b97c180a7d504b9e492a","tests/punycode_tests.json":"3d4ac0cf25984c37b9ce197f5df680a0136f728fb8ec82bc76624e42139eb3a8","tests/tests.rs":"d205a2bfb29dfee73e014faebd3207a55ef0d40121e6dbd52f5d611b37ac111e","tests/unit.rs":"be025a7d9bab3bd1ce134c87f9d848269e157b31ca5ba0ea03426c1ac736b69e","tests/uts46.rs":"06c97bf7dc20f5372b542fa46922d6dd63fe15e0aa34d799d08df9e3a241aa21"},"package":"e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6"}
\ No newline at end of file diff --git a/vendor/idna/Cargo.toml b/vendor/idna/Cargo.toml index 138a27162..fa2ed42bc 100644 --- a/vendor/idna/Cargo.toml +++ b/vendor/idna/Cargo.toml @@ -3,21 +3,21 @@ # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies +# to registry (e.g., crates.io) dependencies. # -# If you believe there's an error in this file please file an -# issue against the rust-lang/cargo repository. If you're -# editing this file be aware that the upstream Cargo.toml -# will likely look very different (and much more reasonable) +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. [package] edition = "2018" +rust-version = "1.51" name = "idna" -version = "0.2.3" +version = "0.3.0" authors = ["The rust-url developers"] autotests = false description = "IDNA (Internationalizing Domain Names in Applications) and Punycode." -license = "MIT/Apache-2.0" +license = "MIT OR Apache-2.0" repository = "https://github.com/servo/rust-url/" [lib] @@ -33,22 +33,21 @@ name = "unit" [[bench]] name = "all" harness = false -[dependencies.matches] -version = "0.1" [dependencies.unicode-bidi] version = "0.3" [dependencies.unicode-normalization] version = "0.1.17" + [dev-dependencies.assert_matches] version = "1.3" [dev-dependencies.bencher] version = "0.1" -[dev-dependencies.rustc-test] -version = "0.3" - [dev-dependencies.serde_json] version = "1.0" + +[dev-dependencies.tester] +version = "0.9" diff --git a/vendor/idna/LICENSE-MIT b/vendor/idna/LICENSE-MIT index 24de6b418..51d5dc7eb 100644 --- a/vendor/idna/LICENSE-MIT +++ b/vendor/idna/LICENSE-MIT @@ -1,4 +1,4 @@ -Copyright (c) 2013-2016 The rust-url developers +Copyright (c) 2013-2022 The rust-url developers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated diff --git a/vendor/idna/src/lib.rs b/vendor/idna/src/lib.rs index b87d4a15e..37d638741 100644 --- a/vendor/idna/src/lib.rs +++ b/vendor/idna/src/lib.rs @@ -32,8 +32,9 @@ //! > that minimizes the impact of this transition for client software, //! > allowing client software to access domains that are valid under either system. +#[cfg(test)] #[macro_use] -extern crate matches; +extern crate assert_matches; pub mod punycode; mod uts46; diff --git a/vendor/idna/src/uts46.rs b/vendor/idna/src/uts46.rs index ad798055f..ec2fd0b10 100644 --- a/vendor/idna/src/uts46.rs +++ b/vendor/idna/src/uts46.rs @@ -156,7 +156,7 @@ fn passes_bidi(label: &str, is_bidi_domain: bool) -> bool { // LTR label BidiClass::L => { // Rule 5 - while let Some(c) = chars.next() { + for c in chars.by_ref() { if !matches!( bidi_class(c), BidiClass::L @@ -318,51 +318,48 @@ fn check_validity(label: &str, config: Config, errors: &mut Errors) { // V8: Bidi rules are checked inside `processing()` } -/// http://www.unicode.org/reports/tr46/#Processing -#[allow(clippy::manual_strip)] // introduced in 1.45, MSRV is 1.36 -fn processing( - domain: &str, - config: Config, - normalized: &mut String, - output: &mut String, -) -> Errors { - // Weed out the simple cases: only allow all lowercase ASCII characters and digits where none - // of the labels start with PUNYCODE_PREFIX and labels don't start or end with hyphen. - let (mut prev, mut simple, mut puny_prefix) = ('?', !domain.is_empty(), 0); +// Detect simple cases: all lowercase ASCII characters and digits where none +// of the labels start with PUNYCODE_PREFIX and labels don't start or end with hyphen. +fn is_simple(domain: &str) -> bool { + if domain.is_empty() { + return false; + } + let (mut prev, mut puny_prefix) = ('?', 0); for c in domain.chars() { if c == '.' { if prev == '-' { - simple = false; - break; + return false; } puny_prefix = 0; continue; } else if puny_prefix == 0 && c == '-' { - simple = false; - break; + return false; } else if puny_prefix < 5 { if c == ['x', 'n', '-', '-'][puny_prefix] { puny_prefix += 1; if puny_prefix == 4 { - simple = false; - break; + return false; } } else { puny_prefix = 5; } } if !c.is_ascii_lowercase() && !c.is_ascii_digit() { - simple = false; - break; + return false; } prev = c; } - if simple { - output.push_str(domain); - return Errors::default(); - } + true +} +/// http://www.unicode.org/reports/tr46/#Processing +fn processing( + domain: &str, + config: Config, + normalized: &mut String, + output: &mut String, +) -> Errors { normalized.clear(); let mut errors = Errors::default(); let offset = output.len(); @@ -384,8 +381,8 @@ fn processing( output.push('.'); } first = false; - if label.starts_with(PUNYCODE_PREFIX) { - match decoder.decode(&label[PUNYCODE_PREFIX.len()..]) { + if let Some(remainder) = label.strip_prefix(PUNYCODE_PREFIX) { + match decoder.decode(remainder) { Ok(decode) => { let start = output.len(); output.extend(decode); @@ -396,7 +393,7 @@ fn processing( } if !errors.is_err() { - if !is_nfc(&decoded_label) { + if !is_nfc(decoded_label) { errors.nfc = true; } else { check_validity(decoded_label, non_transitional, &mut errors); @@ -448,11 +445,13 @@ impl Idna { } } - /// http://www.unicode.org/reports/tr46/#ToASCII - #[allow(clippy::wrong_self_convention)] - pub fn to_ascii<'a>(&'a mut self, domain: &str, out: &mut String) -> Result<(), Errors> { - let mut errors = processing(domain, self.config, &mut self.normalized, &mut self.output); - + pub fn to_ascii_inner(&mut self, domain: &str, out: &mut String) -> Errors { + if is_simple(domain) { + out.push_str(domain); + return Errors::default(); + } + let mut errors = processing(domain, self.config, &mut self.normalized, out); + self.output = std::mem::replace(out, String::with_capacity(out.len())); let mut first = true; for label in self.output.split('.') { if !first { @@ -471,6 +470,13 @@ impl Idna { } } } + errors + } + + /// http://www.unicode.org/reports/tr46/#ToASCII + #[allow(clippy::wrong_self_convention)] + pub fn to_ascii<'a>(&'a mut self, domain: &str, out: &mut String) -> Result<(), Errors> { + let mut errors = self.to_ascii_inner(domain, out); if self.config.verify_dns_length { let domain = if out.ends_with('.') { @@ -492,6 +498,10 @@ impl Idna { /// http://www.unicode.org/reports/tr46/#ToUnicode #[allow(clippy::wrong_self_convention)] pub fn to_unicode<'a>(&'a mut self, domain: &str, out: &mut String) -> Result<(), Errors> { + if is_simple(domain) { + out.push_str(domain); + return Errors::default().into(); + } processing(domain, self.config, &mut self.normalized, out).into() } } @@ -555,7 +565,7 @@ impl Config { /// http://www.unicode.org/reports/tr46/#ToASCII pub fn to_ascii(self, domain: &str) -> Result<String, Errors> { - let mut result = String::new(); + let mut result = String::with_capacity(domain.len()); let mut codec = Idna::new(self); codec.to_ascii(domain, &mut result).map(|()| result) } diff --git a/vendor/idna/tests/punycode.rs b/vendor/idna/tests/punycode.rs index c0123c639..1a51cbc92 100644 --- a/vendor/idna/tests/punycode.rs +++ b/vendor/idna/tests/punycode.rs @@ -63,9 +63,9 @@ pub fn collect_tests<F: FnMut(String, TestFn)>(add_test: &mut F) { }; add_test( test_name, - TestFn::dyn_test_fn(move || { + TestFn::DynTestFn(Box::new(move || { one_test(get_string(&o, "decoded"), get_string(&o, "encoded")) - }), + })), ) } _ => panic!(), diff --git a/vendor/idna/tests/tests.rs b/vendor/idna/tests/tests.rs index 5f0f8cde3..0704c81c1 100644 --- a/vendor/idna/tests/tests.rs +++ b/vendor/idna/tests/tests.rs @@ -1,4 +1,4 @@ -use rustc_test as test; +use tester as test; mod punycode; mod uts46; @@ -8,12 +8,18 @@ fn main() { { let mut add_test = |name, run| { tests.push(test::TestDescAndFn { - desc: test::TestDesc::new(test::DynTestName(name)), + desc: test::TestDesc { + name: test::DynTestName(name), + ignore: false, + should_panic: test::ShouldPanic::No, + allow_fail: false, + test_type: test::TestType::Unknown, + }, testfn: run, }) }; punycode::collect_tests(&mut add_test); uts46::collect_tests(&mut add_test); } - test::test_main(&std::env::args().collect::<Vec<_>>(), tests) + test::test_main(&std::env::args().collect::<Vec<_>>(), tests, None) } diff --git a/vendor/idna/tests/uts46.rs b/vendor/idna/tests/uts46.rs index 72b5bcec7..bd402ce97 100644 --- a/vendor/idna/tests/uts46.rs +++ b/vendor/idna/tests/uts46.rs @@ -8,6 +8,7 @@ use crate::test::TestFn; use std::char; +use std::fmt::Write; use idna::Errors; @@ -25,10 +26,10 @@ pub fn collect_tests<F: FnMut(String, TestFn)>(add_test: &mut F) { }; let mut pieces = line.split(';').map(|x| x.trim()).collect::<Vec<&str>>(); - let source = unescape(&pieces.remove(0)); + let source = unescape(pieces.remove(0)); // ToUnicode - let mut to_unicode = unescape(&pieces.remove(0)); + let mut to_unicode = unescape(pieces.remove(0)); if to_unicode.is_empty() { to_unicode = source.clone(); } @@ -65,7 +66,7 @@ pub fn collect_tests<F: FnMut(String, TestFn)>(add_test: &mut F) { let test_name = format!("UTS #46 line {}", i + 1); add_test( test_name, - TestFn::dyn_test_fn(move || { + TestFn::DynTestFn(Box::new(move || { let config = idna::Config::default() .use_std3_ascii_rules(true) .verify_dns_length(true) @@ -109,7 +110,7 @@ pub fn collect_tests<F: FnMut(String, TestFn)>(add_test: &mut F) { to_ascii_t_result, |e| e.starts_with('C') || e == "V2", ); - }), + })), ) } } @@ -160,8 +161,8 @@ fn unescape(input: &str) -> String { match char::from_u32(((c1 * 16 + c2) * 16 + c3) * 16 + c4) { Some(c) => output.push(c), None => { - output - .push_str(&format!("\\u{:X}{:X}{:X}{:X}", c1, c2, c3, c4)); + write!(&mut output, "\\u{:X}{:X}{:X}{:X}", c1, c2, c3, c4) + .expect("Could not write to output"); } }; } |