summaryrefslogtreecommitdiff
path: root/Lib/test/test_email/test_policy.py
diff options
context:
space:
mode:
authorKrzysztof Wojcik <wojcikk2903@users.noreply.github.com>2019-05-14 18:55:23 +0200
committerVictor Stinner <vstinner@redhat.com>2019-05-14 18:55:23 +0200
commitc1f5667be1e3ec5871560c677402c1252c6018a6 (patch)
tree199ab3f8a68ef855b41a086ce280faff1ca817bf /Lib/test/test_email/test_policy.py
parent4d45a3b1107977baba9dce868e80d1d95bce4085 (diff)
downloadcpython-git-c1f5667be1e3ec5871560c677402c1252c6018a6.tar.gz
bpo-33529, email: Fix infinite loop in email header encoding (GH-12020)
Diffstat (limited to 'Lib/test/test_email/test_policy.py')
-rw-r--r--Lib/test/test_email/test_policy.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_email/test_policy.py b/Lib/test/test_email/test_policy.py
index 8fecb8a5fc..c2c437e6ac 100644
--- a/Lib/test/test_email/test_policy.py
+++ b/Lib/test/test_email/test_policy.py
@@ -237,6 +237,14 @@ class PolicyAPITests(unittest.TestCase):
email.policy.EmailPolicy.header_factory)
self.assertEqual(newpolicy.__dict__, {'raise_on_defect': True})
+ def test_non_ascii_chars_do_not_cause_inf_loop(self):
+ policy = email.policy.default.clone(max_line_length=20)
+ actual = policy.fold('Subject', 'ą' * 12)
+ self.assertEqual(
+ actual,
+ 'Subject: \n' +
+ 12 * ' =?utf-8?q?=C4=85?=\n')
+
# XXX: Need subclassing tests.
# For adding subclassed objects, make sure the usual rules apply (subclass
# wins), but that the order still works (right overrides left).