Skip to content

Commit 46d650c

Browse files
committed
issue2551092 - fix crash due to use of string not bytes under py3
Align roundup.anypy.email_.decode_header which is a copy of the stdlib email.header.decode_header by adding conversion of str to bytes for py3. rouilj: I was unable to figure out how to generate a test case for this. Existing tests that use utf8 encoded subject line pass and in all cases including the ones where I tried to craft a failing subject, always were bytes and not strings.
1 parent 3c11b1a commit 46d650c

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ Fixed:
3939
- issue2551094 - make simplemde handle line breaks the same as the
4040
backend markdown formmatters. (report: Cedric Krier, patch: Christof
4141
Meerwald)
42+
- issue2551092 - fix crash bug by aligning
43+
roundup.anypy.email_.decode_header with stdlib email.header and
44+
convert string to bytes for python 3. (Cedrick Krier)
4245

4346
Features:
4447
- issue2550522 - Add 'filter' command to command-line

roundup/anypy/email_.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ def decode_header(header):
108108
collapsed = []
109109
last_word = last_charset = None
110110
for word, charset in decoded_words:
111-
if isinstance(word, str):
112-
pass
111+
if isinstance(word, str) and bytes != str:
112+
word = bytes(word, 'raw-unicode-escape')
113113
if last_word is None:
114114
last_word = word
115115
last_charset = charset

0 commit comments

Comments
 (0)