Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use "non-strict" parsing for email.utils.getaddresses #4021

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion Products/CMFPlone/PloneTool.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from Acquisition import aq_parent
from ComputedAttribute import ComputedAttribute
from DateTime import DateTime
from email.utils import getaddresses
from OFS.ObjectManager import bad_id
from OFS.SimpleItem import SimpleItem
from plone.base.defaultpage import check_default_page_via_view
Expand Down Expand Up @@ -55,6 +54,7 @@
from zope.interface import implementer
from zope.lifecycleevent import ObjectModifiedEvent

import email.utils
import re
import sys
import transaction
Expand Down Expand Up @@ -95,6 +95,15 @@
METADATA_DC_AUTHORFIELDS = ("Creator", "Contributors", "Publisher")


# use old non-strict parsing behavior
# see https://docs.python.org/3.11/whatsnew/3.11.html#email
# and https://docs.python.org/3.12/whatsnew/3.12.html#id11
def getaddresses(fieldvalues):
if getattr(email.utils, "supports_strict_parsing", False):
return email.utils.getaddresses(fieldvalues, strict=False)
return email.utils.getaddresses(fieldvalues)


@implementer(IPloneTool)
class PloneTool(PloneBaseTool, UniqueObject, SimpleItem):
"""Various utility methods."""
Expand Down
3 changes: 3 additions & 0 deletions news/4020.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Use "non-strict" parsing in `email.utils.getaddresses` newest versions.
See https://docs.python.org/3.12/whatsnew/3.12.html#id11
[petschki]