From 2a99d5df63395149ef7393ef5e8a4fb141f64b55 Mon Sep 17 00:00:00 2001 From: Ezio Melotti Date: Sat, 6 Jul 2013 17:16:04 +0200 Subject: #18380: pass regex flags to the right argument. Patch by Valentina Mukhamedzhanova. --- Lib/email/quoprimime.py | 2 +- Lib/test/test_email/test_email.py | 4 ++++ Misc/ACKS | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Lib/email/quoprimime.py b/Lib/email/quoprimime.py index 78638d5..bc02281 100644 --- a/Lib/email/quoprimime.py +++ b/Lib/email/quoprimime.py @@ -319,4 +319,4 @@ def header_decode(s): the high level email.header class for that functionality. """ s = s.replace('_', ' ') - return re.sub(r'=[a-fA-F0-9]{2}', _unquote_match, s, re.ASCII) + return re.sub(r'=[a-fA-F0-9]{2}', _unquote_match, s, flags=re.ASCII) diff --git a/Lib/test/test_email/test_email.py b/Lib/test/test_email/test_email.py index 78b86b8..8757924 100644 --- a/Lib/test/test_email/test_email.py +++ b/Lib/test/test_email/test_email.py @@ -4048,6 +4048,10 @@ class TestQuopri(unittest.TestCase): def test_header_decode_non_ascii(self): self._test_header_decode('hello=C7there', 'hello\xc7there') + def test_header_decode_re_bug_18380(self): + # Issue 18380: Call re.sub with a positional argument for flags in the wrong position + self.assertEqual(quoprimime.header_decode('=30' * 257), '0' * 257) + def _test_decode(self, encoded, expected_decoded, eol=None): if eol is None: decoded = quoprimime.decode(encoded) diff --git a/Misc/ACKS b/Misc/ACKS index 71402b7..cf64ed2 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -849,6 +849,7 @@ Alessandro Moura Pablo Mouzo Mher Movsisyan Ruslan Mstoi +Valentina Mukhamedzhanova Michael Mulich Sape Mullender Sjoerd Mullender -- cgit v0.12