bpo-33524: Fix the folding of email header when max_line_length is 0 or None (#13391)

and there are non-ascii characters in the header.
This commit is contained in:
Abhilash Raj 2019-05-17 12:28:44 -07:00 committed by R. David Murray
parent cbe72d8426
commit feac6cd775
4 changed files with 20 additions and 2 deletions

View file

@ -68,6 +68,7 @@ XXX: provide complete list of token types.
"""
import re
import sys
import urllib # For urllib.parse.unquote
from string import hexdigits
from operator import itemgetter
@ -2590,7 +2591,7 @@ def _refold_parse_tree(parse_tree, *, policy):
"""
# max_line_length 0/None means no limit, ie: infinitely long.
maxlen = policy.max_line_length or float("+inf")
maxlen = policy.max_line_length or sys.maxsize
encoding = 'utf-8' if policy.utf8 else 'us-ascii'
lines = ['']
last_ew = None