Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SUP-15: fix_leading_dot() cuts in the middle of a quoted character #234

Merged
merged 1 commit into from
Oct 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions flanker/mime/message/part.py
Original file line number Diff line number Diff line change
Expand Up @@ -730,8 +730,8 @@ def _quote_and_cut(ln):

# Should be a quoted character
if c == b'=':
# Peak ahead, do the next 2 chars appear to be a hex values?
if quopri.ishex(ln[pos+1:pos+3]):
# Peak ahead, does the next char appear to be a hex value?
if quopri.ishex(ln[pos+1:pos+2]):
in_quote = 1
continue

Expand Down
8 changes: 8 additions & 0 deletions tests/mime/message/headers/part_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@
'=2Equick brown fox, quick brown cat =09=\n' +
' quick read dog, quic=\n' +
'k white bird'),
# Should avoid cutting in the middle of multiple quoted characters near the cut point
(b'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz' +
b'.foo. \xF0\x9F\x99\x82 also there is \xF0\x9F\x99\x82 more in \xF0\x9F\x99\x82 ' +
b'this \xF0\x9F\x99\x82 message</body></html>',
'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz=\n' +
'=2Efoo. =F0=9F=99=82 also there is =F0=9F=\n' +
'=99=82 more in =F0=9F=99=82 this =F0=\n'
'=9F=99=82 message</body></html>'),
)


Expand Down