Skip to content

Commit fb3b957

Browse files
committed
Don't check hyphens in domain_to_ascii and domain_to_unicode (fixes #483)
1 parent 6e18952 commit fb3b957

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

idna/src/lib.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,12 @@ pub mod uts46;
4747
///
4848
/// This process may fail.
4949
pub fn domain_to_ascii(domain: &str) -> Result<String, uts46::Errors> {
50-
uts46::to_ascii(domain, uts46::Flags {
50+
let flags = uts46::Flags {
5151
use_std3_ascii_rules: false,
5252
transitional_processing: false,
5353
verify_dns_length: false,
54-
})
54+
};
55+
uts46::Config::from(flags).check_hyphens(false).to_ascii(domain)
5556
}
5657

5758
/// The [domain to Unicode](https://url.spec.whatwg.org/#concept-domain-to-unicode) algorithm.
@@ -63,11 +64,12 @@ pub fn domain_to_ascii(domain: &str) -> Result<String, uts46::Errors> {
6364
/// This may indicate [syntax violations](https://url.spec.whatwg.org/#syntax-violation)
6465
/// but always returns a string for the mapped domain.
6566
pub fn domain_to_unicode(domain: &str) -> (String, Result<(), uts46::Errors>) {
66-
uts46::to_unicode(domain, uts46::Flags {
67+
let flags = uts46::Flags {
6768
use_std3_ascii_rules: false,
6869

6970
// Unused:
7071
transitional_processing: false,
7172
verify_dns_length: false,
72-
})
73+
};
74+
uts46::Config::from(flags).check_hyphens(false).to_unicode(domain)
7375
}

0 commit comments

Comments
 (0)