瀏覽代碼

Don't check hyphens in domain_to_ascii and domain_to_unicode (fixes #483)

Anthony Ramine 7 年之前
父節點
當前提交
fb3b957337
共有 1 個文件被更改,包括 6 次插入4 次删除
  1. 6 4
      idna/src/lib.rs

+ 6 - 4
idna/src/lib.rs

@@ -47,11 +47,12 @@ pub mod uts46;
 ///
 /// This process may fail.
 pub fn domain_to_ascii(domain: &str) -> Result<String, uts46::Errors> {
-    uts46::to_ascii(domain, uts46::Flags {
+    let flags = uts46::Flags {
         use_std3_ascii_rules: false,
         transitional_processing: false,
         verify_dns_length: false,
-    })
+    };
+    uts46::Config::from(flags).check_hyphens(false).to_ascii(domain)
 }
 
 /// 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> {
 /// This may indicate [syntax violations](https://url.spec.whatwg.org/#syntax-violation)
 /// but always returns a string for the mapped domain.
 pub fn domain_to_unicode(domain: &str) -> (String, Result<(), uts46::Errors>) {
-    uts46::to_unicode(domain, uts46::Flags {
+    let flags = uts46::Flags {
         use_std3_ascii_rules: false,
 
         // Unused:
         transitional_processing: false,
         verify_dns_length: false,
-    })
+    };
+    uts46::Config::from(flags).check_hyphens(false).to_unicode(domain)
 }