fix(http): relax cookies parser to support HTTP 1.0 and ANSI C timestamp formats#6290
Conversation
|
|
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe changes add support for parsing HTTP 1.0-era date formats with 2-digit years (e.g., "Mon, 20-Oct-25 15:57:56 GMT") to the HTTP date-time format parser. This enables proper handling of legacy cookie Expires timestamps. Tests verify the parsing capability for the new format. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes The changes are straightforward: a single pattern addition to a format list and corresponding test coverage. The modifications are homogeneous and localized. Review effort focuses on verifying the regex pattern correctness, ensuring test cases adequately validate the new format, and confirming no regressions to existing 4-digit year parsing. Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Comment |
Co-authored-by: jerrinot <[email protected]>
jerrinot
left a comment
There was a problem hiding this comment.
looking good, I manually checked 1760975876000000L and it indeed it does represent Mon Oct 20 2025 15:57:56 GMT+0000 as expected.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@copilot add also support for the ANSI C format |
Co-authored-by: jerrinot <[email protected]>
Added support for ANSI C asctime format ( |
[PR Coverage check]😍 pass : 0 / 0 (0%) |
Problem
The HTTP header parser was unable to parse cookie
Expiresvalues with 2-digit year formats (HTTP 1.0 era) and ANSI C asctime formats, resulting in errors like:While these formats are deprecated in favor of 4-digit years per RFC 2616, some legacy systems still use them in the wild. Per RFC 2616 Section 3.3.1, HTTP clients should support three date formats: RFC 1123, RFC 850, and ANSI C asctime.
Solution
Added new HTTP date format patterns to support legacy date formats:
E, d-MMM-yy HH:mm:ss ZE MMM dd HH:mm:ss yyyyandE MMM d HH:mm:ss yyyyThe patterns are added as fallback formats after the standard HTTP and Microsoft EntraID formats, ensuring:
adjustYear()methodChanges
httpPatternsarrayTesting
Mon, 20-Oct-25 15:57:56 GMTcorrectly parses as October 20, 2025Sun Nov 6 08:49:37 1994correctly parses as November 6, 1994Fixes the issue where legitimate but deprecated HTTP cookie dates were being rejected.
Fixes #6289
Original prompt
Fixes #6289
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.