From ea374a13507562e23c1c437f6777e68295714a01 Mon Sep 17 00:00:00 2001 From: Peter Mathis Date: Tue, 8 Oct 2024 14:26:13 +0200 Subject: [PATCH 1/2] Fix for `email.utils.getaddresses` to use the old non-strict parsing behavior --- Products/CMFPlone/PloneTool.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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.""" From 8243eb88831b53db138d65e48d3faf5795e196ee Mon Sep 17 00:00:00 2001 From: Peter Mathis Date: Tue, 8 Oct 2024 14:31:37 +0200 Subject: [PATCH 2/2] changenote --- news/4020.bugfix | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 news/4020.bugfix 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]