innovark37 commented on code in PR #40885:
URL: https://github.com/apache/superset/pull/40885#discussion_r3571268482
##########
superset/reports/notifications/email.py:
##########
@@ -72,11 +74,46 @@
class EmailContent:
body: str
header_data: Optional[HeaderDataType] = None
- data: Optional[dict[str, Any]] = None
+ data: Optional[dict[str, bytes | str]] = None
pdf: Optional[dict[str, bytes]] = None
images: Optional[dict[str, bytes]] = None
+def _get_xlsx_attachment_extension(content: bytes) -> str:
+ """
+ Return the attachment extension for bytes returned by the XLSX export
endpoint.
+ """
+ try:
+ with ZipFile(BytesIO(content)) as zip_file:
+ names = zip_file.namelist()
+ if _is_xlsx_zip(names):
+ return "xlsx"
+
+ files = [name for name in names if not name.endswith("/")]
+ if files and all(name.lower().endswith(".xlsx") for name in files):
+ for name in files:
+ with zip_file.open(name) as xlsx_file:
+ if not _is_xlsx_zipfile(xlsx_file.read()):
+ return "xlsx"
Review Comment:
Fixed.
The XLSX/ZIP classifier no longer reads each embedded workbook fully into
memory. It now only checks the nested file ZIP signature, so detection stays
bounded even for paginated exports with many large workbook files.
--
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]