cookies: same domain handling changed to match browser behavior

Cokie with the same domain but different tailmatching property are now
considered different and do not replace each other.  If header contains
following lines then two cookies will be set: Set-Cookie: foo=bar;
domain=.foo.com; expires=Thu Mar 3 GMT 8:56:27 2033 Set-Cookie: foo=baz;
domain=foo.com; expires=Thu Mar 3 GMT 8:56:27 2033

This matches Chrome, Opera, Safari, and Firefox behavior. When sending
stored tokens to foo.com Chrome, Opera, Firefox store send them in the
stored order, while Safari pre-sort the cookies.

Closes #1050
This commit is contained in:
Sergei Kuzmin 2016-10-02 21:34:59 -07:00 committed by Daniel Stenberg
parent 2a1d538963
commit 54e48b14e1
2 changed files with 34 additions and 23 deletions

View file

@ -817,7 +817,8 @@ Curl_cookie_add(struct Curl_easy *data,
/* the names are identical */
if(clist->domain && co->domain) {
if(Curl_raw_equal(clist->domain, co->domain))
if(Curl_raw_equal(clist->domain, co->domain) &&
(clist->tailmatch == co->tailmatch))
/* The domains are identical */
replace_old=TRUE;
}