cookies: support creation-time attribute for cookies

According to RFC6265 section 5.4, cookies with equal path lengths
SHOULD be sorted by creation-time (earlier first). This adds a
creation-time record to the cookie struct in order to make cookie
sorting more deterministic. The creation-time is defined as the
order of the cookies in the jar, the first cookie read fro the
jar being the oldest. The creation-time is thus not serialized
into the jar. Also remove the strcmp() matching in the sorting as
there is no lexicographic ordering in RFC6265. Existing tests are
updated to match.

Closes #2524
This commit is contained in:
Daniel Gustafsson 2018-08-28 11:28:50 +02:00 committed by Daniel Stenberg
parent b842fa3110
commit e2ef8d6fa1
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
12 changed files with 120 additions and 82 deletions

View file

@ -205,14 +205,14 @@ lock: cookie [Pigs in space]: 86
unlock: cookie [Pigs in space]: 87
loaded cookies:
-----------------
.host.foo.com TRUE / FALSE 1896263787 injected yes
.foo.com TRUE / FALSE 1993463787 test1 overwritten1
.host.foo.com TRUE / FALSE 1896263787 test2 two
.foo.com TRUE / FALSE 1896263787 test3 three
.host.foo.com TRUE / FALSE 2061978987 test4 overwritten4
.host.foo.com TRUE / FALSE 1896263787 test5 five
.www.host.foo.com TRUE / FALSE 1993463787 test6 six
www.host.foo.com FALSE / FALSE 1993463787 test6 six_more
.www.host.foo.com TRUE / FALSE 1993463787 test6 six
.host.foo.com TRUE / FALSE 1896263787 test5 five
.host.foo.com TRUE / FALSE 2061978987 test4 overwritten4
.foo.com TRUE / FALSE 1896263787 test3 three
.host.foo.com TRUE / FALSE 1896263787 test2 two
.foo.com TRUE / FALSE 1993463787 test1 overwritten1
.host.foo.com TRUE / FALSE 1896263787 injected yes
-----------------
try SHARE_CLEANUP...
lock: share [Pigs in space]: 88
@ -236,14 +236,14 @@ http://%HOSTIP:%HTTPPORT/506
# https://curl.haxx.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.
.host.foo.com TRUE / FALSE 1896263787 injected yes
.foo.com TRUE / FALSE 1993463787 test1 overwritten1
.host.foo.com TRUE / FALSE 1896263787 test2 two
.foo.com TRUE / FALSE 1896263787 test3 three
.host.foo.com TRUE / FALSE 2061978987 test4 overwritten4
.host.foo.com TRUE / FALSE 1896263787 test5 five
.www.host.foo.com TRUE / FALSE 1993463787 test6 six
www.host.foo.com FALSE / FALSE 1993463787 test6 six_more
.www.host.foo.com TRUE / FALSE 1993463787 test6 six
.host.foo.com TRUE / FALSE 1896263787 test5 five
.host.foo.com TRUE / FALSE 2061978987 test4 overwritten4
.foo.com TRUE / FALSE 1896263787 test3 three
.host.foo.com TRUE / FALSE 1896263787 test2 two
.foo.com TRUE / FALSE 1993463787 test1 overwritten1
.host.foo.com TRUE / FALSE 1896263787 injected yes
</file>
</verify>
</testcase>