Skip to content

Commit f47e029

Browse files
committed
Move mime-parameter folding to top of loop.
The mime parameter folder doesn't make use of the encoding check done be the code that is now below it, it does its own. So it makes more sense to take that branch first. This will simplify subsequent changes.
1 parent 8f3f6fd commit f47e029

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

Lib/email/_header_value_parser.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2858,6 +2858,11 @@ def _refold_parse_tree(parse_tree, *, policy):
28582858
if part is end_ew_not_allowed:
28592859
wrap_as_ew_blocked -= 1
28602860
continue
2861+
if part.token_type == 'mime-parameters':
2862+
# Mime parameter folding (using RFC2231) is extra special.
2863+
_fold_mime_parameters(part, lines, maxlen, encoding)
2864+
last_word_is_ew = False
2865+
continue
28612866
tstr = str(part)
28622867
if not want_encoding:
28632868
if part.token_type in ('ptext', 'vtext'):
@@ -2879,12 +2884,6 @@ def _refold_parse_tree(parse_tree, *, policy):
28792884
charset = 'utf-8'
28802885
want_encoding = True
28812886

2882-
if part.token_type == 'mime-parameters':
2883-
# Mime parameter folding (using RFC2231) is extra special.
2884-
_fold_mime_parameters(part, lines, maxlen, encoding)
2885-
last_word_is_ew = False
2886-
continue
2887-
28882887
if want_encoding and not wrap_as_ew_blocked:
28892888
if not part.as_ew_allowed:
28902889
want_encoding = False

0 commit comments

Comments
 (0)