ExportXMLWordPrintable

    • b07
    • generic
    • generic

      HttpCookie treats cookies with an unparseable Expires attribute as immediately expired, rather than ignoring the attribute as specified by RFC 6265 section 5.2.1 and the updated getMaxAge() specification from JDK-8359343.

      When expiryDate2DeltaSeconds() fails to parse the date string against all 6 formats, it returns 0. The caller assignMaxAgeAttribute() then executes (delta > 0 ? delta : 0), setting maxAge to 0. Since hasExpired() treats maxAge == 0 as immediately expired, the cookie is discarded.

      The expected behavior per RFC 6265 section 5.2.1 is to ignore the unparseable expires attribute, leaving maxAge at -1 (session cookie).
      This also matches step 4 of the updated getMaxAge() specification: "If previous step failed, then return -1."

      Reproducer:
          HttpCookie cookie = HttpCookie.parse(
              "Set-Cookie: name=value; expires=GARBAGE").get(0);
          System.out.println(cookie.getMaxAge());  // prints 0, expected -1
          System.out.println(cookie.hasExpired()); // prints true, expected false

            Assignee:
            Hyunsu Eun
            Reporter:
            Hyunsu Eun
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: