Commit aef652f
Expire the cookie on Set-Cookie Max-Age=0
`Max-Age=0` is the standard way for a server to delete a cookie, but
readsetcookies dropped the attribute instead of recording it. The
leading-zero guard rejects any value whose first character is '0', which
catches "0" itself, so the parsed Cookie kept `maxage == 0` (attribute
absent) and CookieJar stored the cookie rather than deleting it. A
logout that clears a session with `Set-Cookie: sid=; Path=/; Max-Age=0`
left the stale entry in the jar, to be sent on every later request.
Reject a leading zero only on a non-zero value, and map every
delta-seconds <= 0 to the `maxage == -1` deletion sentinel (RFC 6265
5.2.2). This also closes a round trip inside the package: `stringify`
already serializes a deletion as "Max-Age=0", which the parser could not
read back. `Max-Age=01` is still ignored and positive values are
unchanged.
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>1 parent 769b917 commit aef652f
2 files changed
Lines changed: 36 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
343 | 343 | | |
344 | 344 | | |
345 | 345 | | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
353 | 355 | | |
354 | 356 | | |
355 | 357 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
157 | 184 | | |
158 | 185 | | |
159 | 186 | | |
| |||
0 commit comments