Skip to content

Commit bf477a9

Browse files
authored
bpo-31677: email: Remove re.IGNORECASE flag (pythonGH-3868)
While there is not real bug in this case, using re.IGNORECASE without re.ASCII leads unexpected behavior. Instead of adding re.ASCII, this commit removes re.IGNORECASE flag because it's easier and simpler. This commit removes dead copy of the pattern in email.util module too. While the pattern is same, it is compiled separately because it had different flags.
1 parent e2d0dd2 commit bf477a9

File tree

2 files changed

+2
-14
lines changed

2 files changed

+2
-14
lines changed

Lib/email/header.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@
3636
=\? # literal =?
3737
(?P<charset>[^?]*?) # non-greedy up to the next ? is the charset
3838
\? # literal ?
39-
(?P<encoding>[qb]) # either a "q" or a "b", case insensitive
39+
(?P<encoding>[qQbB]) # either a "q" or a "b", case insensitive
4040
\? # literal ?
4141
(?P<encoded>.*?) # non-greedy up to the next ?= is the encoded string
4242
\?= # literal ?=
43-
''', re.VERBOSE | re.IGNORECASE | re.MULTILINE)
43+
''', re.VERBOSE | re.MULTILINE)
4444

4545
# Field name regexp, including trailing colon, but not separating whitespace,
4646
# according to RFC 2822. Character range is from tilde to exclamation mark.

Lib/email/utils.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -114,18 +114,6 @@ def getaddresses(fieldvalues):
114114
return a.addresslist
115115

116116

117-
118-
ecre = re.compile(r'''
119-
=\? # literal =?
120-
(?P<charset>[^?]*?) # non-greedy up to the next ? is the charset
121-
\? # literal ?
122-
(?P<encoding>[qb]) # either a "q" or a "b", case insensitive
123-
\? # literal ?
124-
(?P<atom>.*?) # non-greedy up to the next ?= is the atom
125-
\?= # literal ?=
126-
''', re.VERBOSE | re.IGNORECASE)
127-
128-
129117
def _format_timetuple_and_zone(timetuple, zone):
130118
return '%s, %02d %s %04d %02d:%02d:%02d %s' % (
131119
['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'][timetuple[6]],

0 commit comments

Comments
 (0)