]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
test1560: skip some URLs if UTF-8 is not supported
authorSergio Durigan Junior <sergiodj@sergiodj.net>
Thu, 17 Jul 2025 09:38:10 +0000 (05:38 -0400)
committerViktor Szakats <commit@vsz.me>
Sat, 19 Jul 2025 20:37:17 +0000 (22:37 +0200)
Debian CI found that `lib1560` implements tests that will fail when
UTF-8 isn't supported.  We can detect that with `nl_langinfo` and skip
the specific URLs that fail (i.e., those whose `getflags` are either
`CURLU_PUNYCODE` or `CURLU_PUNY2IDN`).

Co-authored-by: Viktor Szakats
Closes #17933

tests/libtest/lib1560.c
tests/runtests.pl

index d1fc04359e35b186f24aa868664ca3ee648f6fd7..947283ba8bae68c6712eb6214e8920d6325f5ad9 100644 (file)
@@ -1428,7 +1428,7 @@ static int set_url(void)
    2. Set one or more parts
    3. Extract and compare all parts - not the URL
 */
-static int setget_parts(void)
+static int setget_parts(int has_utf8)
 {
   int i;
   int error = 0;
@@ -1440,6 +1440,10 @@ static int setget_parts(void)
       error++;
       break;
     }
+    if((setget_parts_list[i].getflags == CURLU_PUNYCODE ||
+        setget_parts_list[i].getflags == CURLU_PUNY2IDN) && !has_utf8) {
+      continue;
+    }
     if(setget_parts_list[i].in)
       rc = curl_url_set(urlp, CURLUPART_URL, setget_parts_list[i].in,
                         setget_parts_list[i].urlflags);
@@ -1525,7 +1529,7 @@ static int set_parts(void)
   return error;
 }
 
-static int get_url(void)
+static int get_url(int has_utf8)
 {
   int i;
   int error = 0;
@@ -1536,6 +1540,10 @@ static int get_url(void)
       error++;
       break;
     }
+    if((get_url_list[i].getflags == CURLU_PUNYCODE ||
+        get_url_list[i].getflags == CURLU_PUNY2IDN) && !has_utf8) {
+      continue;
+    }
     rc = curl_url_set(urlp, CURLUPART_URL, get_url_list[i].in,
                       get_url_list[i].urlflags);
     if(!rc) {
@@ -1565,7 +1573,7 @@ static int get_url(void)
   return error;
 }
 
-static int get_parts(void)
+static int get_parts(int has_utf8)
 {
   int i;
   int error = 0;
@@ -1576,6 +1584,10 @@ static int get_parts(void)
       error++;
       break;
     }
+    if((get_parts_list[i].getflags == CURLU_PUNYCODE ||
+        get_parts_list[i].getflags == CURLU_PUNY2IDN) && !has_utf8) {
+      continue;
+    }
     rc = curl_url_set(urlp, CURLUPART_URL,
                       get_parts_list[i].in,
                       get_parts_list[i].urlflags);
@@ -2018,15 +2030,17 @@ err:
 
 static CURLcode test_lib1560(char *URL)
 {
+  int has_utf8 = !!getenv("CURL_TEST_HAVE_CODESET_UTF8");
+
   (void)URL; /* not used */
 
   if(urldup())
     return (CURLcode)11;
 
-  if(setget_parts())
+  if(setget_parts(has_utf8))
     return (CURLcode)10;
 
-  if(get_url())
+  if(get_url(has_utf8))
     return (CURLcode)3;
 
   if(huge())
@@ -2047,7 +2061,7 @@ static CURLcode test_lib1560(char *URL)
   if(set_parts())
     return (CURLcode)2;
 
-  if(get_parts())
+  if(get_parts(has_utf8))
     return (CURLcode)4;
 
   if(clear_url())
index 184483f807f17319c80c02e0c57b707a9a06c114..ced595e559f49860fa92569c60513884e4714f9b 100755 (executable)
@@ -809,6 +809,9 @@ sub checksystemfeatures {
     $feature{"crypto"} = $feature{"NTLM"} || $feature{"Kerberos"} || $feature{"SPNEGO"};
     $feature{"local-http"} = servers::localhttp();
     $feature{"codeset-utf8"} = lc(langinfo(CODESET())) eq "utf-8";
+    if($feature{"codeset-utf8"}) {
+        $ENV{'CURL_TEST_HAVE_CODESET_UTF8'} = 1;
+    }
 
     # make each protocol an enabled "feature"
     for my $p (@protocols) {