innovark37 commented on code in PR #40885:
URL: https://github.com/apache/superset/pull/40885#discussion_r3601577448
##########
superset/utils/core.py:
##########
@@ -120,6 +120,27 @@
logging.getLogger("MARKDOWN").setLevel(logging.INFO)
logger = logging.getLogger(__name__)
+EMAIL_ATTACHMENT_SUBTYPES: dict[str, str] = {
+ ".pdf": "pdf",
+ ".zip": "zip",
+ ".xlsx": "vnd.openxmlformats-officedocument.spreadsheetml.sheet",
+}
+
+
+def build_email_attachment(name: str, body: bytes | str) -> MIMEApplication:
+ """
+ Create an email attachment part with stable filename metadata.
+ """
+ subtype = EMAIL_ATTACHMENT_SUBTYPES.get(os.path.splitext(name)[1].lower())
+ attachment = MIMEApplication(
+ body,
+ _subtype=subtype or "octet-stream",
+ Name=name,
+ )
Review Comment:
Thanks, this is a valid concern. I updated `build_email_attachment` to
normalize `str` bodies to UTF-8 bytes before constructing `MIMEApplication`, so
text attachments have stable bytes regardless of character set. I also added a
regression test for a non-ASCII text attachment payload.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]