summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_email/test_policy.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2019-06-18 00:13:58 (GMT)
committerNed Deily <nad@python.org>2019-06-18 00:13:57 (GMT)
commit516a6a254814d2bc6a90290dfc44d77fdfb4050b (patch)
treec8011e1b47da209cc7dd7424de1b23234f28ec0b /Lib/test/test_email/test_policy.py
parentecafe8e42464b2c91a507fd26de06ce1203dd654 (diff)
downloadcpython-516a6a254814d2bc6a90290dfc44d77fdfb4050b.zip
cpython-516a6a254814d2bc6a90290dfc44d77fdfb4050b.tar.gz
cpython-516a6a254814d2bc6a90290dfc44d77fdfb4050b.tar.bz2
bpo-33529, email: Fix infinite loop in email header encoding (GH-12020) (GH-14162)
(cherry picked from commit c1f5667be1e3ec5871560c677402c1252c6018a6)
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 8fecb8a..c2c437e 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).