Skip to content

Commit 44ff079

Browse files
committed
update
1 parent 21df7d7 commit 44ff079

8 files changed

Lines changed: 31 additions & 33 deletions

File tree

Mailman/Archiver/Archiver.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,7 @@ def GetBaseArchiveURL(self):
132132
if self.archive_private:
133133
return url
134134
else:
135-
hostname = re.match('[^:]*://([^/]*)/.*', url).group(1)\
136-
or mm_cfg.DEFAULT_URL_HOST
135+
hostname = re.match(r'[^:]*://([^/]*)/.*', url, re.IGNORECASE).group(1)
137136
url = mm_cfg.PUBLIC_ARCHIVE_URL % {
138137
'listname': self.internal_name(),
139138
'hostname': hostname

Mailman/Archiver/HyperArch.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,9 @@ def __init__(self, message=None, sequence=0, keepHeaders=[],
278278
i18n.set_language(lang)
279279
if self.author == self.email:
280280
self.author = self.email = re.sub('@', _(' at '),
281-
self.email)
281+
self.email, flags=re.IGNORECASE)
282282
else:
283-
self.email = re.sub('@', _(' at '), self.email)
283+
self.email = re.sub('@', _(' at '), self.email, flags=re.IGNORECASE)
284284
finally:
285285
i18n.set_translation(otrans)
286286

@@ -413,7 +413,7 @@ def decode_headers(self):
413413
i18n.set_language(self._lang)
414414
atmark = str(_(' at '), Utils.GetCharSet(self._lang))
415415
subject = re.sub(r'([-+,.\w]+)@([-+.\w]+)',
416-
r'\g<1>' + atmark + r'\g<2>', subject)
416+
r'\g<1>' + atmark + r'\g<2>', subject, flags=re.IGNORECASE)
417417
finally:
418418
i18n.set_translation(otrans)
419419
self.decoded['subject'] = subject
@@ -426,14 +426,14 @@ def strip_subject(self, subject):
426426
if prefix:
427427
prefix_pat = re.escape(prefix)
428428
prefix_pat = '%'.join(prefix_pat.split(r'\%'))
429-
prefix_pat = re.sub(r'%\d*d', r'\s*\d+\s*', prefix_pat)
430-
subject = re.sub(prefix_pat, '', subject)
429+
prefix_pat = re.sub(r'%\d*d', r'\s*\d+\s*', prefix_pat, flags=re.IGNORECASE)
430+
subject = re.sub(prefix_pat, '', subject, flags=re.IGNORECASE)
431431
subject = subject.lstrip()
432432
# MAS Should we strip FW and FWD too?
433433
strip_pat = re.compile(r'^((RE|AW|SV|VS)(\[\d+\])?:\s*)+', re.I)
434434
stripped = strip_pat.sub('', subject)
435435
# Also remove whitespace to avoid folding/unfolding differences
436-
stripped = re.sub(r'\s', '', stripped)
436+
stripped = re.sub(r'\s', '', stripped, flags=re.IGNORECASE)
437437
return stripped
438438

439439
def decode_charset(self, field):
@@ -469,7 +469,7 @@ def as_html(self):
469469
d["in_reply_to_url"] = url_quote(self._message_id)
470470
if mm_cfg.ARCHIVER_OBSCURES_EMAILADDRS:
471471
# Point the mailto url back to the list
472-
author = re.sub('@', _(' at '), self.author)
472+
author = re.sub('@', _(' at '), self.author, flags=re.IGNORECASE)
473473
emailurl = self._mlist.GetListEmail()
474474
else:
475475
author = self.author
@@ -580,7 +580,7 @@ def as_text(self):
580580
i18n.set_language(self._lang)
581581
atmark = str(_(' at '), cset)
582582
body = re.sub(r'([-+,.\w]+)@([-+.\w]+)',
583-
r'\g<1>' + atmark + r'\g<2>', body)
583+
r'\g<1>' + atmark + r'\g<2>', body, flags=re.IGNORECASE)
584584
finally:
585585
i18n.set_translation(otrans)
586586
# Return body to character set of article.
@@ -916,7 +916,7 @@ def volNameToDesc(self, volname):
916916
_('September'), _('October'), _('November'), _('December')
917917
]
918918
for each in list(self._volre.keys()):
919-
match = re.match(self._volre[each], volname)
919+
match = re.match(self._volre[each], volname, re.IGNORECASE)
920920
# Let ValueErrors percolate up
921921
if match:
922922
year = int(match.group('year'))
@@ -976,7 +976,7 @@ def dateToVolName(self,date):
976976
def volNameToDate(self, volname):
977977
volname = volname.strip()
978978
for each in list(self._volre.keys()):
979-
match = re.match(self._volre[each],volname)
979+
match = re.match(self._volre[each],volname, re.IGNORECASE)
980980
if match:
981981
year = int(match.group('year'))
982982
month = 1
@@ -1052,7 +1052,7 @@ def write_index_entry(self, article):
10521052
author = self.get_header("author", article)
10531053
if mm_cfg.ARCHIVER_OBSCURES_EMAILADDRS:
10541054
try:
1055-
author = re.sub('@', _(' at '), author)
1055+
author = re.sub('@', _(' at '), author, flags=re.IGNORECASE)
10561056
except UnicodeError:
10571057
# Non-ASCII author contains '@' ... no valid email anyway
10581058
pass
@@ -1224,7 +1224,7 @@ def __processbody_URLquote(self, lines):
12241224
text = jr.group(1)
12251225
length = len(text)
12261226
if mm_cfg.ARCHIVER_OBSCURES_EMAILADDRS:
1227-
text = re.sub('@', atmark, text)
1227+
text = re.sub('@', atmark, text, flags=re.IGNORECASE)
12281228
URL = self.maillist.GetScriptURL(
12291229
'listinfo', absolute=1)
12301230
else:

Mailman/Bouncers/DSN.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def process(msg):
8181
header = header.decode('us-ascii', errors='replace')
8282
# Look for IP addresses in Received headers
8383
# Support both IPv4 and IPv6 formats
84-
ip_match = re.search(r'\[([0-9a-fA-F:.]+)\]', header)
84+
ip_match = re.search(r'\[([0-9a-fA-F:.]+)\]', header, re.IGNORECASE)
8585
if ip_match:
8686
ip = ip_match.group(1)
8787
break

Mailman/Defaults.py.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ HTML_TO_PLAIN_TEXT_COMMAND = '/usr/bin/lynx -dump %(filename)s'
177177
# A Python regular expression character class which defines the characters
178178
# allowed in list names. Lists cannot be created with names containing any
179179
# character that doesn't match this class. Do not include '/' in this list.
180-
ACCEPTABLE_LISTNAME_CHARACTERS = '[-+_.=a-z0-9]'
180+
ACCEPTABLE_LISTNAME_CHARACTERS = r'[-+_.=a-z0-9]'
181181

182182
# The number of characters in the longest listname in the installation. The
183183
# fix for LP: #1780874 truncates list names in web URLs to this length to avoid

Mailman/MailList.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@ def __init__(self, name=None, lock=1):
9696
# pipe to the wrapper in an MTA alias or other delivery process
9797
# contains shell special characters so allow only defined characters
9898
# (default = '[-+_.=a-z0-9]').
99-
pattern = mm_cfg.ACCEPTABLE_LISTNAME_CHARACTERS.replace('-', r'\-')
100-
if len(re.sub(r'[%s]' % pattern, '', name, flags=re.IGNORECASE)) > 0:
99+
if not re.match(r'^' + mm_cfg.ACCEPTABLE_LISTNAME_CHARACTERS + r'+$', name, re.IGNORECASE):
101100
raise Errors.BadListNameError(name)
102101
# Validate what will be the list's posting address
103102
postingaddr = '%s@%s' % (name, mm_cfg.DEFAULT_EMAIL_HOST)
@@ -602,7 +601,7 @@ def Create(self, name, admin, crypted_password,
602601
# pipe to the wrapper in an MTA alias or other delivery process
603602
# contains shell special characters so allow only defined characters
604603
# (default = '[-+_.=a-z0-9]').
605-
if len(re.sub(mm_cfg.ACCEPTABLE_LISTNAME_CHARACTERS, '', name)) > 0:
604+
if len(re.sub(r'^' + mm_cfg.ACCEPTABLE_LISTNAME_CHARACTERS + r'+$', '', name, flags=re.IGNORECASE)) > 0:
606605
raise Errors.BadListNameError(name)
607606
# Validate what will be the list's posting address. If that's
608607
# invalid, we don't want to create the mailing list. The hostname

Mailman/Queue/BounceRunner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ def verp_bounce(mlist, msg):
295295
if not to:
296296
continue
297297
try:
298-
mo = re.search(mm_cfg.VERP_REGEXP, to)
298+
mo = re.search(mm_cfg.VERP_REGEXP, to, re.IGNORECASE)
299299
if not mo:
300300
continue
301301
if bmailbox != mo.group('bounces'):
@@ -329,7 +329,7 @@ def verp_probe(mlist, msg):
329329
to = parseaddr(field)[1]
330330
if not to:
331331
continue # empty header
332-
mo = re.search(mm_cfg.VERP_PROBE_REGEXP, to)
332+
mo = re.search(mm_cfg.VERP_PROBE_REGEXP, to, re.IGNORECASE)
333333
if not mo:
334334
continue # no match of regexp
335335
try:

Mailman/Queue/CommandRunner.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ def do_command(self, cmd, args=None):
159159
return BADCMD
160160
if self.subjcmdretried < 1:
161161
self.subjcmdretried += 1
162-
if re.search('^.*:.+', cmd):
163-
cmd = re.sub('.*:', '', cmd).lower()
162+
if re.search(r'^.*:.+', cmd, re.IGNORECASE):
163+
cmd = re.sub(r'.*:', '', cmd).lower()
164164
return self.do_command(cmd, args)
165165
if self.subjcmdretried < 2 and args:
166166
self.subjcmdretried += 1
@@ -329,7 +329,7 @@ def _dispose(self, mlist, msg, msgdata):
329329
elif msgdata.get('toleave'):
330330
ret = res.do_command('leave')
331331
elif msgdata.get('toconfirm'):
332-
mo = re.match(mm_cfg.VERP_CONFIRM_REGEXP, msg.get('to', ''))
332+
mo = re.match(mm_cfg.VERP_CONFIRM_REGEXP, msg.get('to', ''), re.IGNORECASE)
333333
if mo:
334334
ret = res.do_command('confirm', (mo.group('cookie'),))
335335
if ret == BADCMD and mm_cfg.DISCARD_MESSAGE_WITH_NO_COMMAND:

Mailman/Utils.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def list_exists(listname):
100100
#
101101
# But first ensure the list name doesn't contain a path traversal
102102
# attack.
103-
if len(re.sub(mm_cfg.ACCEPTABLE_LISTNAME_CHARACTERS, '', listname)) > 0:
103+
if len(re.sub(mm_cfg.ACCEPTABLE_LISTNAME_CHARACTERS, '', listname, flags=re.IGNORECASE)) > 0:
104104
remote = os.environ.get('HTTP_FORWARDED_FOR',
105105
os.environ.get('HTTP_X_FORWARDED_FOR',
106106
os.environ.get('REMOTE_ADDR',
@@ -146,7 +146,7 @@ def wrap(text, column=70, honor_leading_ws=True):
146146
"""
147147
wrapped = ''
148148
# first split the text into paragraphs, defined as a blank line
149-
paras = re.split('\n\n', text)
149+
paras = re.split(r'\n\n', text)
150150
for para in paras:
151151
# fill
152152
lines = []
@@ -1101,7 +1101,7 @@ def strip_verbose_pattern(pattern):
11011101
elif c == ']' and inclass:
11021102
inclass = False
11031103
newpattern += c
1104-
elif re.search(r'\s', c):
1104+
elif re.search(r'\s', c, re.IGNORECASE):
11051105
if inclass:
11061106
if c == NL:
11071107
newpattern += '\\n'
@@ -1491,7 +1491,7 @@ def check_eq_domains(email, domains_list):
14911491
except ValueError:
14921492
return []
14931493
domain = domain.lower()
1494-
domains_list = re.sub(r'\s', '', domains_list).lower()
1494+
domains_list = re.sub(r'\s', '', domains_list, flags=re.IGNORECASE).lower()
14951495
domains = domains_list.split(';')
14961496
domains_list = []
14971497
for d in domains:
@@ -1526,8 +1526,8 @@ def xml_to_unicode(s, cset):
15261526
"""
15271527
if isinstance(s, bytes):
15281528
us = s.decode(cset, 'replace')
1529-
us = re.sub(u'&(#[0-9]+);', _invert_xml, us)
1530-
us = re.sub(u'(?i)\\\\(u[a-f0-9]{4})', _invert_xml, us)
1529+
us = re.sub(r'&(#[0-9]+);', _invert_xml, us, flags=re.IGNORECASE)
1530+
us = re.sub(r'(?i)\\\\(u[a-f0-9]{4})', _invert_xml, us, flags=re.IGNORECASE)
15311531
return us
15321532
else:
15331533
return s
@@ -1642,8 +1642,8 @@ def banned_domain(email):
16421642
return False
16431643
# Newer versions of dnspython use strings property instead of strings attribute
16441644
text = ans.rrset.to_text() if hasattr(ans, 'rrset') else str(ans)
1645-
if re.search(r'127\.0\.1\.\d{1,3}$', text, re.MULTILINE):
1646-
if not re.search(r'127\.0\.1\.255$', text, re.MULTILINE):
1645+
if re.search(r'127\.0\.1\.\d{1,3}$', text, re.MULTILINE | re.IGNORECASE):
1646+
if not re.search(r'127\.0\.1\.255$', text, re.MULTILINE | re.IGNORECASE):
16471647
return True
16481648
except dns.resolver.NXDOMAIN:
16491649
# Domain not found in blocklist
@@ -1748,4 +1748,4 @@ def ValidateListName(listname):
17481748
if not listname:
17491749
return False
17501750
# Check if the list name contains any characters not in the acceptable pattern
1751-
return len(re.sub(mm_cfg.ACCEPTABLE_LISTNAME_CHARACTERS, '', listname)) == 0
1751+
return len(re.sub(mm_cfg.ACCEPTABLE_LISTNAME_CHARACTERS, '', listname, flags=re.IGNORECASE)) == 0

0 commit comments

Comments
 (0)