Skip to content

Commit

Permalink
Merge pull request #234 from mailgun/thrawn/develop
Browse files Browse the repository at this point in the history
SUP-15: fix_leading_dot() cuts in the middle of a quoted character
  • Loading branch information
thrawn01 committed Oct 24, 2019
2 parents 6a48527 + 2b98a64 commit 4d6a207
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
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

0 comments on commit 4d6a207

Please sign in to comment.