]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
altsvc: accept 'clear' without semicolon as well
authorDaniel Stenberg <daniel@haxx.se>
Sun, 13 Jul 2025 14:32:55 +0000 (16:32 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Sun, 13 Jul 2025 15:02:34 +0000 (17:02 +0200)
Extend test 1654 to verify

Fixes #17917
Reported-by: Luke Wilde
Closes #17918

lib/altsvc.c
tests/unit/unit1654.c

index 2ccd22ef472b7b8a20b15547b297134e3ef41395..59476d7325a49f459e6629f10dbfb35cab31934a 100644 (file)
@@ -486,8 +486,7 @@ CURLcode Curl_altsvc_parse(struct Curl_easy *data,
   DEBUGASSERT(asi);
 
   /* initial check for "clear" */
-  if(!curlx_str_until(&p, &alpn, MAX_ALTSVC_LINE, ';') &&
-     !curlx_str_single(&p, ';')) {
+  if(!curlx_str_cspn(&p, &alpn, ";\n\r")) {
     curlx_str_trimblanks(&alpn);
     /* "clear" is a magic keyword */
     if(curlx_str_casecompare(&alpn, "clear")) {
index bfed95997a34083b0f95537853e0676e1e44e8ca..4eee6a08dd4ab29f9b18c83c069fc76b3e3e6f09 100644 (file)
@@ -95,6 +95,20 @@ static CURLcode test_unit1654(char *arg)
   fail_if(result, "Curl_altsvc_parse(7) failed!");
   fail_unless(Curl_llist_count(&asi->list) == 10, "wrong number of entries");
 
+  result =
+    Curl_altsvc_parse(curl, asi,
+                      "h2=\":443\", h3=\":443\"; "
+                      "persist = \"1\"; ma = 120;\r\n",
+                      ALPN_h1, "curl.se", 80);
+  fail_if(result, "Curl_altsvc_parse(6) failed!");
+  fail_unless(Curl_llist_count(&asi->list) == 12, "wrong number of entries");
+
+  /* clear - without semicolon */
+  result = Curl_altsvc_parse(curl, asi, "clear\r\n",
+                             ALPN_h1, "curl.se", 80);
+  fail_if(result, "Curl_altsvc_parse(7) failed!");
+  fail_unless(Curl_llist_count(&asi->list) == 10, "wrong number of entries");
+
   /* only a non-existing alpn */
   result = Curl_altsvc_parse(curl, asi,
                              "h6=\"example.net:443\"; ma=\"180\";\r\n",