urlencode attachment filenames to avoid some recursion depth exceeded error when message is converted to bytes
This commit is contained in:
@@ -17,6 +17,7 @@ import sys
|
|||||||
|
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
|
|
||||||
|
import urllib.parse
|
||||||
import email.message, email.parser, email.policy
|
import email.message, email.parser, email.policy
|
||||||
from email.utils import parsedate_to_datetime, formatdate, formataddr
|
from email.utils import parsedate_to_datetime, formatdate, formataddr
|
||||||
|
|
||||||
@@ -140,6 +141,8 @@ 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")
|
||||||
|
|
||||||
|
filename = urllib.parse.quote_plus(filename)
|
||||||
|
|
||||||
# Python 3.6.
|
# Python 3.6.
|
||||||
if isinstance(blob, str):
|
if isinstance(blob, str):
|
||||||
msg.add_attachment(
|
msg.add_attachment(
|
||||||
|
|||||||
Reference in New Issue
Block a user