Skip to content

Commit

Permalink
cookie: handle spaces after the name in Set-Cookie
Browse files Browse the repository at this point in the history
"name =value" is fine and the space should just be skipped.

Updated test 31 to also test for this.

Bug: #195
Reported-by: cromestant
Help-by: Frank Gevaerts
  • Loading branch information
bagder committed Apr 1, 2015
1 parent b121633 commit 2685041
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/cookie.c
Expand Up @@ -407,7 +407,7 @@ Curl_cookie_add(struct SessionHandle *data,
do {
/* we have a <what>=<this> pair or a stand-alone word here */
name[0]=what[0]=0; /* init the buffers */
if(1 <= sscanf(ptr, "%" MAX_NAME_TXT "[^;\r\n =]=%"
if(1 <= sscanf(ptr, "%" MAX_NAME_TXT "[^;\r\n =] =%"
MAX_COOKIE_LINE_TXT "[^;\r\n]",
name, what)) {
/* Use strstore() below to properly deal with received cookie
Expand Down
8 changes: 8 additions & 0 deletions tests/data/test31
Expand Up @@ -53,6 +53,10 @@ Set-Cookie: test2=yes; domain=se; expires=Sat Feb 2 11:56:27 GMT 2030
Set-Cookie: magic=yessir; path=/silly/; HttpOnly
Set-Cookie: blexp=yesyes; domain=127.0.0.1; domain=127.0.0.1; expiry=totally bad;
Set-Cookie: partialip=nono; domain=.0.0.1;
Set-Cookie: withspaces= yes within and around ;
Set-Cookie: withspaces2 =before equals;
Set-Cookie: prespace= yes before;
Set-Cookie: securewithspace=after ; secure =

boo
</data>
Expand Down Expand Up @@ -124,6 +128,10 @@ Accept: */*
127.0.0.1 FALSE /we/want/ FALSE 2054030187 nodomain value
#HttpOnly_127.0.0.1 FALSE /silly/ FALSE 0 magic yessir
127.0.0.1 FALSE /we/want/ FALSE 0 blexp yesyes
127.0.0.1 FALSE /we/want/ FALSE 0 withspaces yes within and around
127.0.0.1 FALSE /we/want/ FALSE 0 withspaces2 before equals
127.0.0.1 FALSE /we/want/ FALSE 0 prespace yes before
127.0.0.1 FALSE /we/want/ TRUE 0 securewithspace after
</file>
</verify>
</testcase>

0 comments on commit 2685041

Please sign in to comment.