python / python/cpython

AddressHeader problem when FriendlyName is improperly quoted and contains comma

Offen
#143,938 12 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

stdlib topic-email type-bug
Vorherrschende Sprache
Python
Sterne
77.2k
Forks
35.9k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

Bug report

Bug description:

Given an address text of the form: John Smith, Jr <johnsmith@example.com>
Because of the unquoted comma, the text is parsed as two addresses:
"John" <@smith>, "Jr" <johnsmith@example.com>
This is of greatest concern if the object is supposed to be a SingleAddressHeader.

I have also encountered TO and CC strings that have incomplete address specifications, containing only a Friendly Name. For these messages, I am only interested in the valid addresses, although others may want the existing behavior.

To work around both the parsing problem and the invalid address terms, I created a sub-class which discards any address where username or domain are not strings. My workaround does not correct for the incomplete Friendly Name, but it ensures a correct count of valid addresses. It would be desirable to implement a trap for unquoted commas, but there are so many challenges to parsing address lists correctly, I wonder if fixing the unquoted comma problem will create other headaches.

Problem observed on Python 3.11.3150.0 and Python 3.8.1

CPython versions tested on:

3.11

Operating systems tested on:

Windows

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginnen Sie mit dem Parsing-Verhalten von CPython für AddressHeader und reproduzieren Sie die Beispiele für ein nicht in Anführungszeichen gesetztes Komma und einen unvollständigen Adressterm in den gemeldeten Python-Versionen. Lesen Sie die Diskussion in den Kommentaren, bevor Sie die erwartete Behandlung festlegen; als abgeschlossen gilt die Aufgabe, wenn ein abgestimmtes Verhalten für ungültige oder mehrdeutig geparste Adresseinträge feststeht.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
backend
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.