Fix a crash when you can't get an attachment filename (#32)

Co-authored-by: giacom0c <giacomoc7@protonmail.com>
This commit is contained in:
giacom0c
2025-02-01 03:45:53 +01:00
committed by GitHub
parent e9a45164d6
commit e08d296478
+5 -1
View File
@@ -198,7 +198,11 @@ def process_attachment(msg, entry, doc):
mime_type = props.get('ATTACH_MIME_TAG', 'application/octet-stream')
if isinstance(mime_type, bytes): mime_type = mime_type.decode("utf8")
filename = os.path.basename(filename)
try:
filename = os.path.basename(filename)
except (TypeError, ValueError) as e:
logger.warning("Warning in processing attachment filename: {}".format(str(e)))
filename = 'attachment'
# Python 3.6.
if isinstance(blob, str):