]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
url: if IDNA conversion fails, fallback to Transitional
authorDaniel Stenberg <daniel@haxx.se>
Sun, 10 Jan 2021 14:35:48 +0000 (15:35 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Sun, 10 Jan 2021 23:21:28 +0000 (00:21 +0100)
This improves IDNA2003 compatiblity.

Reported-by: Bubu on github
Fixes #6423
Closes #6428

lib/url.c

index 60ba56dae63c41cf1db1e5422f378fd609452088..ab56760de12e7d2b5e32f9d7fdcaabae55bcff94 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -1541,6 +1541,11 @@ CURLcode Curl_idnconvert_hostname(struct connectdata *conn,
       int flags = IDN2_NFC_INPUT;
 #endif
       int rc = idn2_lookup_ul((const char *)host->name, &ace_hostname, flags);
+      if(rc != IDN2_OK)
+        /* fallback to TR46 Transitional mode for better IDNA2003
+           compatibility */
+        rc = idn2_lookup_ul((const char *)host->name, &ace_hostname,
+                            IDN2_TRANSITIONAL);
       if(rc == IDN2_OK) {
         host->encalloc = (char *)ace_hostname;
         /* change the name pointer to point to the encoded hostname */