cookie: cap expire times to 400 days

The pending cookie RFC update (currently known as 6265bis draft-19) says

  Let cookie-age-limit be the maximum age of the cookie (which name of
  Max-Age and an attribute-value of expiry-time. SHOULD be 400 days or
  less.

This change makes received cookies over the wire get capped to 400 days.

It does not cap the expiry date of cookies loaded from file.

It does this by rounding the expire time to a even minute. This, to
allow the test suite to do the same and have a chance to get the same
number for stable testing without requiring a debug build.

The test script generates TWO numbers in the output file for each
%days[] used in the input test file, and the function that subsequently
compares and verifies output is fine with *either* of the two numbers.

This is done so that if the test case is generated the second
immediately before curl runs, that updated expiry number is also deemed
okay. It still checks for an exact match of either number.

Closes #15937
This commit is contained in:
Daniel Stenberg 2025-01-08 10:19:26 +01:00
parent 533dc84e6e
commit 386f570df6
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
10 changed files with 103 additions and 46 deletions

View file

@ -78,15 +78,9 @@ Proxy-Connection: Keep-Alive
# https://curl.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.
%if large-time
.example.com TRUE / FALSE 17545593600 test7value test7
.example.com TRUE / FALSE 17545593600 test4value test4
.example.com TRUE / FALSE 17545593600 test2value test2
%else
.example.com TRUE / FALSE 2145830400 test7value test7
.example.com TRUE / FALSE 2145830400 test4value test4
.example.com TRUE / FALSE 2145830400 test2value test2
%endif
.example.com TRUE / FALSE %days[400] test7value test7
.example.com TRUE / FALSE %days[400] test4value test4
.example.com TRUE / FALSE %days[400] test2value test2
.example.com TRUE / FALSE 0 test1value test1
</file>
</verify>

View file

@ -115,11 +115,7 @@ test31.curl FALSE /we/want/ FALSE 0 withspaces2 before equals
test31.curl FALSE /we/want/ FALSE 0 withspaces yes within and around
.test31.curl TRUE /we/want/ FALSE 0 blexp yesyes
#HttpOnly_test31.curl FALSE /silly/ FALSE 0 magic yessir
%if large-time
test31.curl FALSE /we/want/ FALSE 17517902187 nodomain value
%else
test31.curl FALSE /we/want/ FALSE 2118138987 nodomain value
%endif
test31.curl FALSE /we/want/ FALSE %days[400] nodomain value
.test31.curl TRUE / FALSE 0 partmatch present
#HttpOnly_.test31.curl TRUE /p4/ FALSE 0 httponly myvalue1
#HttpOnly_.test31.curl TRUE /p4/ FALSE 0 httpo4 value4

View file

@ -91,15 +91,14 @@ domain..tld FALSE /want/ FALSE 0 simplyhuge zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
domain..tld FALSE / FALSE 0 justaname
domain..tld FALSE / FALSE 0 ASPSESSIONIDQGGQQSJJ GKNBDIFAAOFDPDAIEAKDIBKE
domain..tld FALSE / FALSE 0 ckySession temporary
domain..tld FALSE / FALSE %days[400] ckyPersistent permanent
%if large-time
domain..tld FALSE / FALSE 17517902187 ckyPersistent permanent
domain..tld FALSE /want FALSE 0 empty
#HttpOnly_domain..tld FALSE /want FALSE 22139150993 mooo2 indeed2
domain..tld FALSE / FALSE 22139150993 mooo indeed
www.loser.com FALSE / FALSE 22139150993 UID 99
www.fake.come FALSE / FALSE 22147483647 cookiecliente si
%else
domain..tld FALSE / FALSE 2118138987 ckyPersistent permanent
domain..tld FALSE /want FALSE 0 empty
#HttpOnly_domain..tld FALSE /want FALSE 2139150993 mooo2 indeed2
domain..tld FALSE / FALSE 2139150993 mooo indeed

View file

@ -58,9 +58,9 @@ Accept: */*
# This file was generated by libcurl! Edit at your own risk.
127.0.0.1 FALSE / FALSE 0 name4 value
127.0.0.1 FALSE / FALSE 5115959787 name3 value
127.0.0.1 FALSE / FALSE %days[400] name3 value
127.0.0.1 FALSE / FALSE 0 name2 value
127.0.0.1 FALSE / FALSE 5115959787 name value
127.0.0.1 FALSE / FALSE %days[400] name value
</file>
</verify>
</testcase>

View file

@ -210,14 +210,14 @@ lock: cookie [Pigs in space]: 90
unlock: cookie [Pigs in space]: 91
loaded cookies:
-----------------
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
www.host.foo.com FALSE / FALSE %days[400] test6 six_more
.www.host.foo.com TRUE / FALSE %days[400] test6 six
.host.foo.com TRUE / FALSE %days[400] test5 five
.host.foo.com TRUE / FALSE %days[400] test4 overwritten4
.foo.com TRUE / FALSE %days[400] test3 three
.host.foo.com TRUE / FALSE %days[400] test2 two
.foo.com TRUE / FALSE %days[400] test1 overwritten1
.host.foo.com TRUE / FALSE %days[400] injected yes
-----------------
try SHARE_CLEANUP...
lock: share [Pigs in space]: 92
@ -238,14 +238,14 @@ GLOBAL_CLEANUP
# https://curl.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.
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
www.host.foo.com FALSE / FALSE %days[400] test6 six_more
.www.host.foo.com TRUE / FALSE %days[400] test6 six
.host.foo.com TRUE / FALSE %days[400] test5 five
.host.foo.com TRUE / FALSE %days[400] test4 overwritten4
.foo.com TRUE / FALSE %days[400] test3 three
.host.foo.com TRUE / FALSE %days[400] test2 two
.foo.com TRUE / FALSE %days[400] test1 overwritten1
.host.foo.com TRUE / FALSE %days[400] injected yes
</file>
</verify>
</testcase>

View file

@ -71,13 +71,8 @@ Accept: */*
# https://curl.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.
%if large-time
.host.foo.com TRUE /we/want/ FALSE 17517902187 test2 yes
#HttpOnly_.foo.com TRUE /we/want/ FALSE 17517902187 test yes
%else
.host.foo.com TRUE /we/want/ FALSE 2118138987 test2 yes
#HttpOnly_.foo.com TRUE /we/want/ FALSE 2118138987 test yes
%endif
.host.foo.com TRUE /we/want/ FALSE %days[400] test2 yes
#HttpOnly_.foo.com TRUE /we/want/ FALSE %days[400] test yes
</file>
</verify>
</testcase>