mirror of
https://github.com/simple-login/app.git
synced 2024-11-10 17:35:27 +08:00
failover when ascii encoding fails
This commit is contained in:
parent
44c3ac1741
commit
b2f9479bce
1 changed files with 5 additions and 1 deletions
|
@ -622,7 +622,11 @@ def parseaddr_unicode(addr) -> (str, str):
|
|||
|
||||
def copy(msg: Message) -> Message:
|
||||
"""return a copy of message"""
|
||||
return email.message_from_bytes(to_bytes(msg))
|
||||
try:
|
||||
return email.message_from_bytes(to_bytes(msg))
|
||||
except UnicodeEncodeError:
|
||||
LOG.warning("to_bytes() fails, try string")
|
||||
return email.message_from_string(msg.as_string())
|
||||
|
||||
|
||||
def to_bytes(msg: Message):
|
||||
|
|
Loading…
Reference in a new issue