diff --git a/flanker/mime/message/part.py b/flanker/mime/message/part.py index d35c934c..c69b1da3 100644 --- a/flanker/mime/message/part.py +++ b/flanker/mime/message/part.py @@ -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 diff --git a/tests/mime/message/headers/part_test.py b/tests/mime/message/headers/part_test.py index 8ffc9fbd..c375e373 100644 --- a/tests/mime/message/headers/part_test.py +++ b/tests/mime/message/headers/part_test.py @@ -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', + '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'), )