fix(email): decode MIME alternatives without duplicating bodies (#6953)

This commit is contained in:
red person
2026-11-03 00:39:55 +00:00
committed by GitHub
parent b7ab0a37c1
commit 682662d36f
4 changed files with 123 additions and 38 deletions
+13
View File
@@ -0,0 +1,13 @@
"""Shared MIME text decoding for the web email helpers and MCP server."""
def decode_text_part(part) -> str:
payload = part.get_payload(decode=True)
if not payload:
return ""
charset = part.get_content_charset() or "utf-8"
try:
return payload.decode(charset, errors="replace")
except (LookupError, ValueError):
# Broken senders can label valid UTF-8 with an unsupported codec.
return payload.decode("utf-8", errors="replace")