Skip to content

Commit

Permalink
python#18380: pass regex flags to the right argument. Patch by Valent…
Browse files Browse the repository at this point in the history
…ina Mukhamedzhanova.
  • Loading branch information
ezio-melotti committed Jul 6, 2013
1 parent 5f3fef3 commit 2a99d5d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Lib/email/quoprimime.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 4 additions & 0 deletions Lib/test/test_email/test_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -4048,6 +4048,10 @@ def test_header_decode_two_lines(self):
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)
Expand Down
1 change: 1 addition & 0 deletions Misc/ACKS
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,7 @@ Alessandro Moura
Pablo Mouzo
Mher Movsisyan
Ruslan Mstoi
Valentina Mukhamedzhanova
Michael Mulich
Sape Mullender
Sjoerd Mullender
Expand Down

0 comments on commit 2a99d5d

Please sign in to comment.