update
This commit is contained in:
14
.CondaPkg/env/Lib/email/policy.py
vendored
14
.CondaPkg/env/Lib/email/policy.py
vendored
@@ -21,7 +21,7 @@ __all__ = [
|
||||
'HTTP',
|
||||
]
|
||||
|
||||
linesep_splitter = re.compile(r'\n|\r')
|
||||
linesep_splitter = re.compile(r'\n|\r\n?')
|
||||
|
||||
@_extend_docstrings
|
||||
class EmailPolicy(Policy):
|
||||
@@ -205,13 +205,21 @@ class EmailPolicy(Policy):
|
||||
if hasattr(value, 'name'):
|
||||
return value.fold(policy=self)
|
||||
maxlen = self.max_line_length if self.max_line_length else sys.maxsize
|
||||
lines = value.splitlines()
|
||||
# We can't use splitlines here because it splits on more than \r and \n.
|
||||
lines = linesep_splitter.split(value)
|
||||
refold = (self.refold_source == 'all' or
|
||||
self.refold_source == 'long' and
|
||||
(lines and len(lines[0])+len(name)+2 > maxlen or
|
||||
any(len(x) > maxlen for x in lines[1:])))
|
||||
if refold or refold_binary and _has_surrogates(value):
|
||||
|
||||
if not refold:
|
||||
if not self.utf8:
|
||||
refold = not value.isascii()
|
||||
elif refold_binary:
|
||||
refold = _has_surrogates(value)
|
||||
if refold:
|
||||
return self.header_factory(name, ''.join(lines)).fold(policy=self)
|
||||
|
||||
return name + ': ' + self.linesep.join(lines) + self.linesep
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user