DicksonWu654 opened a new pull request, #949:
URL: https://github.com/apache/httpcomponents-client/pull/949

   RFC 6265 section 5.1.1 parses a cookie date from its time, day-of-month, 
month and year tokens, and it never compares the weekday name against the date. 
The strict and IE-medium specs use `BasicExpiresHandler` with 
`DateUtils.STANDARD_PATTERNS`, and those formatters do check the weekday. So 
`Set-Cookie: a=b; Expires=Mon, 01 Jan 2030 00:00:00 GMT` (1 Jan 2030 is a 
Tuesday) is rejected even though the date itself is fine.
   
   `BasicExpiresHandler` now tries the configured patterns first, exactly as 
before. Only if that parse fails does it retry with copies of the same patterns 
that leave `DAY_OF_WEEK` out of resolution and use strict date validation. The 
retry formatters are built once in the constructor. The example above now gets 
an expiry of `2030-01-01T00:00:00Z`, and a matching weekday parses as before. 
The patterns, two-digit year handling and time zone handling are unchanged, and 
impossible dates such as `Mon, 31 Feb 2030 00:00:00 GMT` are still rejected as 
malformed.
   
   Another way to fix this would be to use `LaxExpiresHandler`, which 
implements the 5.1.1 token algorithm, in the strict spec as well. That also 
changes which dates the strict spec accepts (missing GMT, reordered tokens, the 
1601 year floor and more), so I left that to you and kept this change to the 
weekday only.
   
   This is the third of the three cookie items from the [email protected] 
thread. Tests were added to `TestBasicCookieAttribHandlers` and 
`TestRFC6265CookieSpec` for a mismatched weekday, a correct weekday, and 30 and 
31 February.
   
   `./mvnw -pl httpclient5 -am verify` on master (28844736) passes: 1162 tests, 
with Checkstyle, RAT and japicmp passing.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to