Opened 4 months ago

Last modified 11 days ago

#28690 assigned Bug

django.utils.http.parse_http_date two digit year check is incorrect

Reported by: Mads Jensen Owned by: Alexander Vyushkov
Component: Utilities Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: yes UI/UX: no


RFC 850 does not mention this, but in RFC 7231 (and there's something similar in RFC 2822), there's the following quote:

Recipients of a timestamp value in rfc850-date format, which uses a
two-digit year, MUST interpret a timestamp that appears to be more
than 50 years in the future as representing the most recent year in
the past that had the same last two digits.

The < 70 is incorrect, and should have been < 50. I inserted a diff that applies.

Attachments (1)

parse-http-date-year.patch (2.1 KB) - added by Mads Jensen 4 months ago.

Download all attachments as: .zip

Change History (9)

Changed 4 months ago by Mads Jensen

Attachment: parse-http-date-year.patch added

comment:1 Changed 4 months ago by Claude Paroz

Component: UncategorizedUtilities
Triage Stage: UnreviewedAccepted

Accepted, however I don't think your patch is correct. The check should be relative to the current year, if I read the RFC quote correctly.

comment:2 Changed 4 months ago by Alexander Vyushkov

Owner: changed from nobody to Alexander Vyushkov
Status: newassigned

comment:3 Changed 4 months ago by Alexander Vyushkov

Has patch: set

Created a pull request: Created a pull request:

comment:4 Changed 3 months ago by Levi Payne

Triage Stage: AcceptedReady for checkin

comment:5 Changed 3 months ago by Levi Payne

Triage Stage: Ready for checkinAccepted

Still some suggested edits on the PR.

comment:6 Changed 3 months ago by Tim Graham

Patch needs improvement: set

comment:7 Changed 2 weeks ago by Alexander Vyushkov

Patch needs improvement: unset

I added regression test that fails with old code (test_parsing_rfc850_year_69), updated commit message to hopefully follow the guidelines, and added additional comments about the change. Squashed commits as well.
Could you review the pull request again?

comment:8 Changed 11 days ago by Tim Graham

Patch needs improvement: set
Note: See TracTickets for help on using tickets.
Back to Top