bpo-27737: Allow whitespace only headers encoding (GH-13478) (#13517)

(cherry picked from commit ef5bb25e2d)

Co-authored-by: Batuhan Taşkaya <47358913+isidentical@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2019-05-22 18:41:43 -07:00 committed by R. David Murray
parent 367fe5757a
commit 0416d6f05a
3 changed files with 6 additions and 1 deletions

View File

@ -431,7 +431,7 @@ class _ValueFormatter:
if end_of_line != (' ', ''):
self._current_line.push(*end_of_line)
if len(self._current_line) > 0:
if self._current_line.is_onlyws():
if self._current_line.is_onlyws() and self._lines:
self._lines[-1] += str(self._current_line)
else:
self._lines.append(str(self._current_line))

View File

@ -4964,6 +4964,9 @@ A very long line that must get split to something other than at the
msg['SomeHeader'] = ' value with leading ws'
self.assertEqual(str(msg), "SomeHeader: value with leading ws\n\n")
def test_whitespace_header(self):
self.assertEqual(Header(' ').encode(), ' ')
# Test RFC 2231 header parameters (en/de)coding

View File

@ -0,0 +1,2 @@
Allow whitespace only header encoding in ``email.header`` - by Batuhan
Taskaya