git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 0/3] test-suite fixes for upcoming curl 8.18.0

From
Jeff King <peff@peff.net>
Date
Dec 19, 2025, 08:04 UTC
Message-ID
<20251219080409.GC3784564@coredump.intra.peff.net>
In-Reply-To
<sn7p46s1-4o20-q05n-173r-s6716s8145q6@unkk.fr>
On Thu, Dec 18, 2025 at 05:49:27PM +0100, Daniel Stenberg wrote:
Show 12 quoted lines
> On Thu, 18 Dec 2025, Daniel Stenberg wrote:
> 
> > >  [3/3]: t5563: relax whitespace assumptions for unfolded headers
> 
> > I did not fully consider the impact this might have on users such as
> > you. Allow me to rework that a little bit further and get the former
> > white-space behavior back. Thanks!
> 
> I just merged a fix [1] into curl that should restore the unfolding behavior
> to match previous releases. It would be awesome if you could verify.
> 
> [1] = https://github.com/curl/curl/commit/9941e7c95bf26f00fd87888a

Thanks, I took a look at it. Unfortunately I think it only gets us halfway there. It drops the extra space when folding this:

  printf 'Foo: bar\r\n'
  printf ' \r\n'
  printf ' baz\r\n'
which will yield:
  Foo: bar baz

and it fixes the first of Git's failing tests. But if we swap out the space for a tab like this:

  printf 'Foo: bar\r\n'
  printf ' \r\n'
  printf '\tbaz\r\n'
then we get collapsed whitespace, but it's a tab. I.e.:
  Foo: bar\tbaz

(where "\t" is a literal tab). I think that does violate the standard (which says it should become spaces). I think in most headers the grammar allows OWS/RWS fields that are spaces or tabs, so in theory it shouldn't matter. But I wouldn't be surprised if that causes some surprises in the real world.

Sadly the input buffer to http_parse_headers() is const, so we can't just write a space over the original tab. ;) But I think rather than walking back to preserve that final leading whitespace byte, we could just always add in our own space separately, like this:

diff --git a/lib/http.c b/lib/http.c
index ea62219542..eaa8bf73c2 100644
--- a/lib/http.c
+++ b/lib/http.c
@@ -4388,6 +4388,7 @@ static CURLcode http_parse_headers(struct Curl_easy *data,
     {
       /* preserve the whole original header piece size */
       size_t header_piece = consumed;
+      bool did_unfold = false;
 
       if(data->state.leading_unfold) {
         /* immediately after an unfold, keep only a single whitespace */
@@ -4398,17 +4399,18 @@ static CURLcode http_parse_headers(struct Curl_easy *data,
           blen--;
         }
         if(consumed) {
-          if(iblen > blen) {
-            /* take one step back */
-            consumed++;
-            buf--;
-            blen++;
-          }
           data->state.leading_unfold = FALSE; /* done now */
+          did_unfold = TRUE;
         }
       }
 
       if(consumed) {
+        if (did_unfold) {
+          result = curlx_dyn_addn(&data->state.headerb, " ", 1);
+          if(result)
+            return result;
+        }
+
         result = curlx_dyn_addn(&data->state.headerb, buf, consumed);
         if(result)
           return result;

-Peff
Previous: Daniel StenbergNext: Daniel Stenberg
Message 10 of 14 in “test-suite fixes for upcoming curl 8.18.0”
  1. 0/3 test-suite fixes for upcoming curl 8.18.0Jeff King, Dec 18, 2025
  2. 1/3 t5551: handle trailing slashes in expected cookies outputJeff King, Dec 18, 2025
  3. 2/3 t5563: add missing end-of-line in HTTP headerJeff King, Dec 18, 2025
  4. Matthew John CheethamDec 18, 2025
  5. Jeff KingDec 19, 2025
  6. 3/3 t5563: relax whitespace assumptions for unfolded headersJeff King, Dec 18, 2025
  7. Matthew John CheethamDec 18, 2025
  8. Daniel StenbergDec 18, 2025
  9. Daniel StenbergDec 18, 2025
  10. Jeff KingDec 19, 2025
  11. Daniel StenbergDec 19, 2025
  12. Jeff KingDec 19, 2025
  13. Junio C HamanoDec 20, 2025
  14. Jeff KingDec 19, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.