]> git.feebdaed.xyz Git - 0xmirror/curl.git/commitdiff
http: fix for unfolding line starting with TAB
authorDaniel Stenberg <daniel@haxx.se>
Fri, 19 Dec 2025 08:15:40 +0000 (09:15 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 19 Dec 2025 09:52:39 +0000 (10:52 +0100)
It should still insert a (single) space when unfolding

Follow-up to 9941e7c95bf26f00fd87888a3 following up to 67ae101666f10232.

Updated test 1274 and 1940 accordingly.

Closes #20029

lib/http.c
tests/data/test1274
tests/data/test1940
tests/libtest/lib1940.c

index fce6c7ccb826e5e9dc0ff2dd250056e506ca6f36..d0f044bf3c2057cc72385e0d8f4c4b936d3e8325 100644 (file)
@@ -4391,19 +4391,16 @@ static CURLcode http_parse_headers(struct Curl_easy *data,
 
       if(data->state.leading_unfold) {
         /* immediately after an unfold, keep only a single whitespace */
-        const size_t iblen = blen;
         while(consumed && ISBLANK(buf[0])) {
           consumed--;
           buf++;
           blen--;
         }
         if(consumed) {
-          if(iblen > blen) {
-            /* take one step back */
-            consumed++;
-            buf--;
-            blen++;
-          }
+          /* insert a single space */
+          result = curlx_dyn_addn(&data->state.headerb, " ", 1);
+          if(result)
+            return result;
           data->state.leading_unfold = FALSE; /* done now */
         }
       }
index 2f40b5d69df72e5c31f28c37d4fcedb5befd7de6..0cac3b05197db7d9727a95e8ab3e8157f0557c17 100644 (file)
@@ -16,6 +16,9 @@ Date: Tue, 09 Nov 2010 14:49:00 GMT%CR
 Server: test-server/%CR
  fake%CR
  folded%CR
+Tabs: tab-instead/%TAB%CR
+%TABonly%CR
+%TAB mixed%CR
 Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT%CR
 ETag: "21025-dc7-39462498"%CR
 Content-Length: 6%CR
@@ -52,6 +55,7 @@ Accept: */*
 HTTP/1.1 200 OK
 Date: Tue, 09 Nov 2010 14:49:00 GMT
 Server: test-server/ fake folded
+Tabs: tab-instead/ only mixed
 Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT
 ETag: "21025-dc7-39462498"
 Content-Length: 6
index 597adf851ba7510a8638a4139d3e05b4f1bb6bf8..e8f7d44e95941306a858b8f49f8a8387c5200057 100644 (file)
@@ -17,6 +17,9 @@ Fold: is
  folding a%repeat[5 x  ]%
    line
 Content-Length: 0
+Test:%TAB
+%TAB%SP
+%TABword
 Set-Cookie: onecookie=data;
 Set-Cookie: secondcookie=2data;
 Set-Cookie: cookie3=data3;
@@ -62,6 +65,7 @@ http://%HOSTIP:%HTTPPORT/%TESTNUMBER
  Fold == is folding a line
  Blank ==%SP
  Blank2 ==%SP
+ Test == word
 </stdout>
 </verify>
 </testcase>
index 66aa63b46b7b1536334da0ac9416dbdc1da760b5..a9114216a18155e7eabc0b474a701bf3de42fba6 100644 (file)
@@ -44,6 +44,7 @@ static void t1940_showem(CURL *curl, int header_request, unsigned int type)
     "fold",
     "blank",
     "Blank2",
+    "Test",
     NULL
   };