http: fix for unfolding line starting with TAB

It should still insert a (single) space when unfolding

Follow-up to 9941e7c95b following up to 67ae101666.

Updated test 1274 and 1940 accordingly.

Closes #20029
This commit is contained in:
Daniel Stenberg 2025-12-19 09:15:40 +01:00
parent 481f11d96f
commit 6c7bc9871f
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
4 changed files with 13 additions and 7 deletions

View 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 */
}
}