From c47888a5f906d335d701092ab6372d7c5f860db2 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Fri, 22 Sep 2023 13:17:58 +0200 Subject: [PATCH] [PR #7303/f4237dde backport][stable-7] Fix incorrect parsing of headers containing equal character (#7306) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix incorrect parsing of headers containing equal character (#7303) * Fix incorrect parsing of header containing equal character * Add changelog fragment * Update changelogs/fragments/7303-mail-incorrect-header-parsing.yml Co-authored-by: Felix Fontein --------- Co-authored-by: Felix Fontein (cherry picked from commit f4237dde1bd0093438705edd52006cc40470dc45) Co-authored-by: Théo Lévesque --- changelogs/fragments/7303-mail-incorrect-header-parsing.yml | 2 ++ plugins/modules/mail.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/7303-mail-incorrect-header-parsing.yml diff --git a/changelogs/fragments/7303-mail-incorrect-header-parsing.yml b/changelogs/fragments/7303-mail-incorrect-header-parsing.yml new file mode 100644 index 0000000000..a35f5288d7 --- /dev/null +++ b/changelogs/fragments/7303-mail-incorrect-header-parsing.yml @@ -0,0 +1,2 @@ +bugfixes: + - mail - skip headers containing equals characters due to missing ``maxsplit`` on header key/value parsing (https://github.com/ansible-collections/community.general/pull/7303). diff --git a/plugins/modules/mail.py b/plugins/modules/mail.py index 117aa4e363..b7542ea0b3 100644 --- a/plugins/modules/mail.py +++ b/plugins/modules/mail.py @@ -354,7 +354,7 @@ def main(): # NOTE: Backward compatible with old syntax using '|' as delimiter for hdr in [x.strip() for x in header.split('|')]: try: - h_key, h_val = hdr.split('=') + h_key, h_val = hdr.split('=', 1) h_val = to_native(Header(h_val, charset)) msg.add_header(h_key, h_val) except Exception: