Fix a crash when you can't get an attachment filename (#32)
Co-authored-by: giacom0c <giacomoc7@protonmail.com>
This commit is contained in:
@@ -198,7 +198,11 @@ def process_attachment(msg, entry, doc):
|
|||||||
mime_type = props.get('ATTACH_MIME_TAG', 'application/octet-stream')
|
mime_type = props.get('ATTACH_MIME_TAG', 'application/octet-stream')
|
||||||
if isinstance(mime_type, bytes): mime_type = mime_type.decode("utf8")
|
if isinstance(mime_type, bytes): mime_type = mime_type.decode("utf8")
|
||||||
|
|
||||||
|
try:
|
||||||
filename = os.path.basename(filename)
|
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.
|
# Python 3.6.
|
||||||
if isinstance(blob, str):
|
if isinstance(blob, str):
|
||||||
|
|||||||
Reference in New Issue
Block a user