diff --git a/Products/CMFPlone/PloneTool.py b/Products/CMFPlone/PloneTool.py index 0c549327a2..983c0ea6a7 100644 --- a/Products/CMFPlone/PloneTool.py +++ b/Products/CMFPlone/PloneTool.py @@ -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 @@ -55,6 +54,7 @@ from zope.interface import implementer from zope.lifecycleevent import ObjectModifiedEvent +import email.utils import re import sys import transaction @@ -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.""" diff --git a/news/4020.bugfix b/news/4020.bugfix new file mode 100644 index 0000000000..785a096111 --- /dev/null +++ b/news/4020.bugfix @@ -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]