]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
headers: make sure the trailing newline is not stored
authorDaniel Stenberg <daniel@haxx.se>
Wed, 10 Jan 2024 08:22:59 +0000 (09:22 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 10 Jan 2024 12:57:08 +0000 (13:57 +0100)
extended test1940 to verify blank header fields too

Bug: https://curl.se/mail/lib-2024-01/0019.html
Reported-by: Dmitry Karpov
Closes #12675

lib/headers.c
tests/data/test1940
tests/data/test421
tests/libtest/lib1940.c

index b6fcdda777cfdf34544b3ec30d29672c21dd19f7..9c29238993aec4fcef3b73c6e997c2342dc412b4 100644 (file)
@@ -295,7 +295,7 @@ CURLcode Curl_headers_push(struct Curl_easy *data, const char *header,
     if(!end)
       return CURLE_BAD_FUNCTION_ARGUMENT;
   }
-  hlen = end - header + 1;
+  hlen = end - header;
 
   if((header[0] == ' ') || (header[0] == '\t')) {
     if(data->state.prevhead)
index 7f621b428df0617e21d3dab976bf18dd2297feb7..f4c6dd1a1a6bc349f105cbc85b349a41e5519113 100644 (file)
@@ -19,6 +19,8 @@ Content-Length: 0
 Set-Cookie: onecookie=data;
 Set-Cookie: secondcookie=2data;
 Set-Cookie: cookie3=data3;
+Blank:
+Blank2:\r
 Location: /%TESTNUMBER0002
 
 </data>
@@ -57,6 +59,8 @@ http://%HOSTIP:%HTTPPORT/%TESTNUMBER
 - Set-Cookie == secondcookie=2data; (1/3)
 - Set-Cookie == cookie3=data3; (2/3)
  Fold == is folding a line
+ Blank == 
+ Blank2 == 
 </stdout>
 </verify>
 </testcase>
index 0e4130b0645cc16d7f4ed6735616c9bc44c0ed8e..2c79c1f8f16de5edb13ddaff2c4a3a94a79111db 100644 (file)
@@ -71,7 +71,7 @@ Accept: */*
 "access-control-allow-methods":["GET, POST, PUT, DELETE, OPTIONS"],
 "access-control-max-age":["1728000"],
 "access-control-allow-headers":["Authorization, Content-Type, AuthorizationOauth, X-EARLY-ACCESS"],
-"access-control-expose-headers":["\r"],
+"access-control-expose-headers":[""],
 "etag":["W/\"2678f9ab2ba550d164e7cc014aefd31e\""],
 "cache-control":["max-age=0, private, must-revalidate"],
 "x-request-id":["375b343b3d2ecf9b442c0daf00fc4a9a"],
index 8bc094362164a939098036a2a5c89a881bef1e83..05da9de3009e9635eb4b278191e4c509f0ccf1f4 100644 (file)
@@ -35,6 +35,8 @@ static const char *show[]={
   "set-cookie",
   "silly-thing",
   "fold",
+  "blank",
+  "Blank2",
   NULL
 };