Commit 9284e6c2 authored by Ezio Melotti's avatar Ezio Melotti

#18380: pass regex flags to the right argument. Patch by Valentina Mukhamedzhanova.

parent 54fe4afd
...@@ -319,4 +319,4 @@ def header_decode(s): ...@@ -319,4 +319,4 @@ def header_decode(s):
the high level email.header class for that functionality. the high level email.header class for that functionality.
""" """
s = s.replace('_', ' ') 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)
...@@ -4048,6 +4048,10 @@ class TestQuopri(unittest.TestCase): ...@@ -4048,6 +4048,10 @@ class TestQuopri(unittest.TestCase):
def test_header_decode_non_ascii(self): def test_header_decode_non_ascii(self):
self._test_header_decode('hello=C7there', 'hello\xc7there') 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): def _test_decode(self, encoded, expected_decoded, eol=None):
if eol is None: if eol is None:
decoded = quoprimime.decode(encoded) decoded = quoprimime.decode(encoded)
......
...@@ -849,6 +849,7 @@ Alessandro Moura ...@@ -849,6 +849,7 @@ Alessandro Moura
Pablo Mouzo Pablo Mouzo
Mher Movsisyan Mher Movsisyan
Ruslan Mstoi Ruslan Mstoi
Valentina Mukhamedzhanova
Michael Mulich Michael Mulich
Sape Mullender Sape Mullender
Sjoerd Mullender Sjoerd Mullender
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment