summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorJoel Hillacre <joel@403forbidden.ca>2017-07-06 21:29:09 (GMT)
committerR. David Murray <rdmurray@bitdance.com>2017-07-06 21:29:09 (GMT)
commit3bbdf990a2c1b0b303b950058e3177a1bd5f697a (patch)
treeb2ebc2b052ae6ab7547d4101590ee7545c0d4c70 /Lib/test
parent710cc7667c27955272725729775cb39c40cca113 (diff)
downloadcpython-3bbdf990a2c1b0b303b950058e3177a1bd5f697a.zip
cpython-3bbdf990a2c1b0b303b950058e3177a1bd5f697a.tar.gz
cpython-3bbdf990a2c1b0b303b950058e3177a1bd5f697a.tar.bz2
bpo-30532: Fix whitespace folding in certain cases (#2592)
Leading whitespace was incorrectly dropped during folding of certain lines in the _header_value_parser's folding algorithm. This makes the whitespace handling code consistent.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_email/test__header_value_parser.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_email/test__header_value_parser.py b/Lib/test/test_email/test__header_value_parser.py
index f7ac0e3..b1e7dff 100644
--- a/Lib/test/test_email/test__header_value_parser.py
+++ b/Lib/test/test_email/test__header_value_parser.py
@@ -2711,5 +2711,17 @@ class TestFolding(TestEmailBase):
self._test(parser.get_unstructured('xxx ' + 'y'*77),
'xxx \n ' + 'y'*77 + '\n')
+ def test_long_filename_attachment(self):
+ folded = self.policy.fold('Content-Disposition', 'attachment; filename="TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TES.txt"')
+ self.assertEqual(
+ 'Content-Disposition: attachment;\n filename="TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TES.txt"\n',
+ folded
+ )
+ folded = self.policy.fold('Content-Disposition', 'attachment; filename="TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_T.txt"')
+ self.assertEqual(
+ 'Content-Disposition: attachment;\n filename="TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_T.txt"\n',
+ folded
+ )
+
if __name__ == '__main__':
unittest.main()