http.cookiejar.http2time raises ValueError instead of returning None for a strict-format fake month
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 77.2k
- Fork
- 35.9k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
Bug description
http.cookiejar.http2time() documents that it returns None for an
unrecognized date format, but its STRICT_DATE_RE fast path raises a raw
ValueError when the month field matches the pattern [JFMASOND][a-z][a-z]
yet names a month that does not exist:
>>> from http.cookiejar import http2time
>>> http2time('Wed, 09 Foo 1994 22:23:32 GMT')
Traceback (most recent call last):
...
ValueError: 'foo' is not in list
>>> http2time('Wed, 09 Feb 1994 22:23:32 GMT') # a real month still works
760832612.0
The slower parser (_str2time) already handles the same input via
try/except and returns None; only the strict fast path leaks. It is
reachable from parse_ns_headers() through a cookie's expires= attribute,
e.g. Set-Cookie: x=y; expires=Wed, 09 Foo 1994 22:23:32 GMT.
gh-60385 previously established the "returns None, never raises" contract
for a different http2time code path; the later STRICT_DATE_RE fast path
reintroduced a leak on this separate path.
CPython versions tested on
3.13, 3.14, 3.15
Operating systems tested on
Linux, macOS
Linked PRs
- gh-153678
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia dal modulo http.cookiejar di Python tracciando http2time() attraverso il fast path STRICT_DATE_RE e confrontandolo con la gestione dei mesi non validi da parte di _str2time. La modifica è completata quando un mese fittizio in formato strict restituisce None senza sollevare eccezioni, mentre un mese valido continua a essere analizzato correttamente; considera il percorso di scadenza dei cookie di parse_ns_headers() descritto nell’issue.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- networking
- Tipo di issue
- Bug
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 35/100