Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cookie handling changed to match most browsers behavior. #1050

Closed
wants to merge 2 commits into from
Closed

Cookie handling changed to match most browsers behavior. #1050

wants to merge 2 commits into from

Conversation

ksa-real
Copy link
Contributor

@ksa-real ksa-real commented Oct 3, 2016

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, and Firefox send them in the
stored order, while Safari pre-sort the cookies.

Cokie with the same 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.
@mention-bot
Copy link

@ksa-real, thanks for your PR! By analyzing the history of the files in this pull request, we identified @umgnay, @bagder and @bgilbert to be potential reviewers.

@bagder bagder added the HTTP label Oct 3, 2016
@@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer having the second condition within parentheses too, to make it easier for readers of the code to figure out precedence.

Copy link
Member

@bagder bagder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from that little nit, this looks like a small and elegant fix and even with a test case so I think we can merge once fixed.

@bagder bagder closed this in 54e48b1 Oct 3, 2016
@bagder
Copy link
Member

bagder commented Oct 3, 2016

thanks!

@lock lock bot locked as resolved and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging this pull request may close these issues.

3 participants