← Back to Pull requests

fix: parse cookie Expires using RFC 6265 cookie-date algorithm #6217

Open
matthewalberto opened this pull request with 251 lines diff across 2 files
View on GitHub
matthewalberto matthewalberto commented on Nov 17, 2026 03:09 UTC
Author

This relates to...

Fixes #6216

Rationale

The current Expires parser uses JavaScript's general-purpose Date parser instead of the cookie-date algorithm specified in RFC 6265 section 5.1.1.

This produces incorrect results for timezone-less dates, explicit timezone offsets and two-digit years. It also accepts values that do not satisfy the cookie-date algorithm.

Changes

Features

N/A

Bug Fixes

  • Add parseCookieDate() in lib/web/cookies/parse.js to implement the RFC 6265 cookie-date algorithm.

  • Replace general-purpose JavaScript date parsing for the Expires attribute.

  • Add 30 test cases in test/cookie/cookies.js, covering valid and invalid cookie dates, timezone independence, two-digit years, token ordering and date boundaries.

  • Return null for invalid cookie dates so the existing cookie handling logic ignores the attribute.
  • Breaking Changes and Deprecations

    ISO timestamps and date-only strings that were previously accepted by JavaScript's date parser will no longer be accepted as Expires values unless they satisfy the RFC 6265 cookie-date algorithm.

    This is an intentional compatibility change to align parsing with the specification. Whether this change requires a semver-major release is left to the maintainers.

    Status

  • I have read and agreed to the Developer's Certificate of Origin

  • Tested

  • [S] Benchmarked (optional)

  • [S] Documented

  • Review ready

  • In review

  • Merge ready
  • Verification details

  • Cookie tests: 125/125 passing.

  • Tested in local time (UTC+8) and with TZ=UTC.

  • ESLint clean on both changed files.

  • Against the original parser, 19 of the 30 new test cases fail in UTC+8 and 15 fail in UTC.

  • The full undici test suite has not yet been run.

  • Chrome and Firefox interoperability for the specific edge cases has not yet been verified.
  • AI assistance disclosure

    The parseCookieDate() implementation and the new test cases were written with an AI coding agent. I reviewed the change, ran the verification probe and the cookie test suite myself, and checked the results against RFC 6265 section 5.1.1.

    Diff: 251 lines (+248 / -3) across 2 files Reviewer: mcollina Review duration: 10935m
    All Vouch review confidence checks passed
    Residual risk 0.12 = Change Risk (0.38) × (1 − Review Confidence (0.67)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.38 · 251 lines diff across 2 files
    0.38
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.55 · 2 substantive comment(s)
    0.55
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    66%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.331
    Real PR Conversation Timeline
    4 items
    mcollina mcollina commented on Nov 17, 2026 07:22 UTC
    Contributor

    @khafradev ptal

    mcollina mcollina approved these changes on Nov 17, 2026 07:22 UTC
    Approved Reviewer

    lgtm

    codecov-commenter codecov-commenter commented on Nov 17, 2026 07:41 UTC
    Contributor

    Codecov Report


    :white_check_mark: All modified and coverable lines are covered by tests.
    :white_check_mark: Project coverage is 91.70%. Comparing base (02c4f8c) to head (52f09e5).
    :warning: Report is 2 commits behind head on main.

    <details><summary>Additional details and impacted files</summary>

    @@            Coverage Diff             @@
    ##             main    #6217      +/-   ##
    ==========================================
    + Coverage   91.68%   91.70%   +0.02%     
    ==========================================
      Files         113      113              
      Lines       44462    44644     +182     
    ==========================================
    + Hits        40763    40943     +180     
    - Misses       3699     3701       +2     
    

    </details>

    :umbrella: View full report in Codecov by Harness.
    :loudspeaker: Have feedback on the report? Share it here.
    <details><summary> :rocket: New features to boost your workflow: </summary>

  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

  • </details>

    Reviewers
    Assignees
    matthewalberto matthewalberto
    Labels
    risk: low confidence: 66.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 37.5% (MEDIUM) · Higher = larger blast radius
    37.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 66.8% · Lower = rushed or shallow review
    66.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 12.5% · Safe to merge
    12.5%
    Repository