-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix exception in
MsgInfo.msg_id
when email body contains 8 bit char…
…acters
- Loading branch information
1 parent
8b20644
commit a0c94c6
Showing
2 changed files
with
25 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
# SPDX-License-Identifier: MIT | ||
|
||
from datetime import datetime as DateTime | ||
from email.message import Message | ||
from io import BytesIO | ||
|
||
from boltons.timeutils import LocalTZ | ||
|
@@ -43,6 +44,25 @@ def test_can_parse_encoded_header(): | |
assert msg_info.from_addr == '[email protected]' | ||
assert msg_info.to_addrs == ('[email protected]',) | ||
|
||
def test_can_parse_message_with_utf8_data(): | ||
msg = Message() | ||
msg['Message-ID'] = '<[email protected]>' | ||
msg['Mime-Version'] = '1.0' | ||
msg['Content-Transfer-Encoding'] = '8bit' | ||
msg['Content-Type'] = 'text/plain; charset=UTF-8' | ||
msg.set_payload(b'some \xc2\xbbnon-ascii\xc2\xab text') | ||
|
||
queue_fp = build_queued_message( | ||
sender='[email protected]', | ||
recipient='[email protected]', | ||
msg=msg, | ||
) | ||
msg_info = parse_message_envelope(queue_fp) | ||
assert msg_info.from_addr == '[email protected]' | ||
assert msg_info.to_addrs == ('[email protected]',) | ||
assert msg_info.msg_id == '[email protected]' | ||
assert msg_info.msg_fp.read() == msg.as_bytes() | ||
|
||
def test_can_parse_queue_metadata(): | ||
queue_date = DateTime(2020, 10, 1, hour=15, minute=42, second=21, tzinfo=LocalTZ) | ||
last_attempt = DateTime(2020, 10, 1, hour=16, minute=0, tzinfo=LocalTZ) | ||
|