http.cookies.BaseCookie.load() applies partial state before raising CookieError
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 77.2k
- Forks
- 35.9k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
Bug description
BaseCookie.load() parses the cookie string in two phases: parse then apply. The comment says it rejects the string if syntactically invalid. However, _is_legal_key() validation runs during the apply phase (inside Morsel.set()), not the parse phase. Cookies before an illegal key are applied to the jar before CookieError is raised.
from http.cookies import SimpleCookie, CookieError
C = SimpleCookie()
try:
C.load("a=1; b,c=2; d=3")
except CookieError:
pass
print(len(C)) # 1, expected 0
Related to gh-84183 but distinct: that issue is about raise-vs-silent for different invalid inputs; this is about partial state when CookieError IS raised.
CPython versions tested on
3.13, 3.14, main
Operating systems tested on
macOS
Linked PRs
- gh-154674
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginnen Sie bei http.cookies.BaseCookie.load() und reproduzieren Sie das Problem mit dem im Report gezeigten Cookie-String. Überprüfen Sie, dass ein CookieError das Cookie-Jar leer lässt; der Issue-Text verlinkt PR gh-154674, prüfen Sie diese Arbeit, bevor Sie fortfahren.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- networking
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 25/100