Merge pull request #886 from simple-login/ac-fix-unauthorized-email
Do not assume all parts in multipart messages are processed as messages
This commit is contained in:
commit
7a0fd34823
|
@ -970,7 +970,10 @@ def add_header(msg: Message, text_header, html_header) -> Message:
|
|||
elif content_type in ("multipart/alternative", "multipart/related"):
|
||||
new_parts = []
|
||||
for part in msg.get_payload():
|
||||
new_parts.append(add_header(part, text_header, html_header))
|
||||
if isinstance(part, Message):
|
||||
new_parts.append(add_header(part, text_header, html_header))
|
||||
else:
|
||||
new_parts.append(part)
|
||||
clone_msg = copy(msg)
|
||||
clone_msg.set_payload(new_parts)
|
||||
return clone_msg
|
||||
|
|
|
@ -283,7 +283,7 @@ def get_or_create_reply_to_contact(
|
|||
return contact
|
||||
else:
|
||||
LOG.d(
|
||||
"create contact %s for alias %s via reply-to header",
|
||||
"create contact %s for alias %s via reply-to header %s",
|
||||
contact_address,
|
||||
alias,
|
||||
reply_to_header,
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
Content-Type: multipart/alternative; boundary="===============5006593052976639648=="
|
||||
MIME-Version: 1.0
|
||||
Subject: My subject
|
||||
From: foo@example.org
|
||||
To: bar@example.net
|
||||
|
||||
--===============5006593052976639648==
|
||||
Content-Type: text/plain; charset="us-ascii"
|
||||
MIME-Version: 1.0
|
||||
Content-Transfer-Encoding: 7bit
|
||||
|
||||
This is HTML
|
||||
--===============5006593052976639648==
|
||||
Content-Type: text/html; charset="us-ascii"
|
||||
MIME-Version: 1.0
|
||||
Content-Transfer-Encoding: 7bit
|
||||
|
||||
<html>
|
||||
<body>
|
||||
This is <i>HTML</i>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
--===============5006593052976639648==--
|
||||
|
|
@ -823,3 +823,15 @@ def test_dmarc_result_na():
|
|||
def test_dmarc_result_bad_policy():
|
||||
msg = load_eml_file("dmarc_bad_policy.eml")
|
||||
assert DmarcCheckResult.bad_policy == get_spamd_result(msg).dmarc
|
||||
|
||||
|
||||
def test_add_header_multipart_with_invalid_part():
|
||||
msg = load_eml_file("multipart_alternative.eml")
|
||||
parts = msg.get_payload() + ["invalid"]
|
||||
msg.set_payload(parts)
|
||||
msg = add_header(msg, "INJECT", "INJECT")
|
||||
for i, part in enumerate(msg.get_payload()):
|
||||
if i < 2:
|
||||
assert part.get_payload().index("INJECT") > -1
|
||||
else:
|
||||
assert part == "invalid"
|
||||
|
|
Loading…
Reference in New Issue