Skip to content

Commit

Permalink
Respect new "strict parsing" of emails.utils.getaddresses [6.0] (#4033
Browse files Browse the repository at this point in the history
)

* Respect new strict parsing of `email.utils.getaddresses`

* changenote

* cleanup address and check early for empty value
  • Loading branch information
petschki authored Oct 17, 2024
1 parent 044e2e6 commit 90d3b81
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Products/CMFPlone/PloneTool.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ def validateSingleNormalizedEmailAddress(self, address):
if not isinstance(address, str):
return False

address = address.strip()

# address can be empty if getaddresses has parsing errors (returns [("", "")])
if address == "":
return False

sub = EMAIL_CUTOFF_RE.match(address)
if sub is not None:
# Address contains two newlines (possible spammer relay attack)
Expand Down
1 change: 0 additions & 1 deletion Products/CMFPlone/tests/testPloneTool.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ def testvalidateEmailAddresses(self):
validInputs = (
"[email protected]",
"[email protected],\n [email protected]",
"[email protected]\n [email protected]", # omitting comma is ok
"[email protected],\n [email protected]",
)
invalidInputs = (
Expand Down
2 changes: 2 additions & 0 deletions news/4020.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Update for strict parsing in `email.utils.getaddresses` newest versions.
[petschki]

0 comments on commit 90d3b81

Please sign in to comment.