diff --git a/Mailman/Archiver/HyperArch.py b/Mailman/Archiver/HyperArch.py index 469e6f5e..14f68b8c 100644 --- a/Mailman/Archiver/HyperArch.py +++ b/Mailman/Archiver/HyperArch.py @@ -419,7 +419,7 @@ def decode_headers(self): i18n.set_language(self._lang) atmark = _(' at ') subject = re.sub(r'([-+,.\w]+)@([-+.\w]+)', - '\g<1>' + atmark + '\g<2>', subject) + r'\g<1>' + atmark + r'\g<2>', subject) finally: i18n.set_translation(otrans) self.decoded['subject'] = subject @@ -589,7 +589,7 @@ def as_text(self): if isinstance(atmark, bytes): atmark = str(atmark, cset) body = re.sub(r'([-+,.\w]+)@([-+.\w]+)', - '\g<1>' + atmark + '\g<2>', body) + r'\g<1>' + atmark + r'\g<2>', body) finally: i18n.set_translation(otrans) diff --git a/Mailman/Bouncers/SimpleMatch.py b/Mailman/Bouncers/SimpleMatch.py index 7f1672e5..b8f36097 100644 --- a/Mailman/Bouncers/SimpleMatch.py +++ b/Mailman/Bouncers/SimpleMatch.py @@ -49,11 +49,11 @@ def _c(pattern): # robanal.demon.co.uk (_c('this message was created automatically by mail delivery software'), _c('original message follows'), - _c('rcpt to:\s*<(?P[^>]*)>')), + _c(r'rcpt to:\s*<(?P[^>]*)>')), # s1.com (InterScan E-Mail VirusWall NT ???) (_c('message from interscan e-mail viruswall nt'), _c('end of message'), - _c('rcpt to:\s*<(?P[^>]*)>')), + _c(r'rcpt to:\s*<(?P[^>]*)>')), # Smail (_c('failed addresses follow:'), _c('message text follows:'), @@ -61,74 +61,74 @@ def _c(pattern): # newmail.ru (_c('This is the machine generated message from mail service.'), _c('--- Below the next line is a copy of the message.'), - _c('<(?P[^>]*)>')), + _c(r'<(?P[^>]*)>')), # turbosport.com runs something called `MDaemon 3.5.2' ??? (_c('The following addresses did NOT receive a copy of your message:'), _c('--- Session Transcript ---'), - _c('[>]\s*(?P.*)$')), + _c(r'[>]\s*(?P.*)$')), # usa.net - (_c('Intended recipient:\s*(?P.*)$'), + (_c(r'Intended recipient:\s*(?P.*)$'), _c('--------RETURNED MAIL FOLLOWS--------'), - _c('Intended recipient:\s*(?P.*)$')), + _c(r'Intended recipient:\s*(?P.*)$')), # hotpop.com - (_c('Undeliverable Address:\s*(?P.*)$'), + (_c(r'Undeliverable Address:\s*(?P.*)$'), _c('Original message attached'), - _c('Undeliverable Address:\s*(?P.*)$')), + _c(r'Undeliverable Address:\s*(?P.*)$')), # Another demon.co.uk format (_c('This message was created automatically by mail delivery'), _c('^---- START OF RETURNED MESSAGE ----'), - _c("addressed to '(?P[^']*)'")), + _c(r"addressed to '(?P[^']*)'")), # Prodigy.net full mailbox (_c("User's mailbox is full:"), _c('Unable to deliver mail.'), - _c("User's mailbox is full:\s*<(?P[^>]*)>")), + _c(r"User's mailbox is full:\s*<(?P[^>]*)>")), # Microsoft SMTPSVC (_c('The email below could not be delivered to the following user:'), _c('Old message:'), - _c('<(?P[^>]*)>')), + _c(r'<(?P[^>]*)>')), # Yahoo on behalf of other domains like sbcglobal.net - (_c('Unable to deliver message to the following address\(es\)\.'), - _c('--- Original message follows\.'), - _c('<(?P[^>]*)>:')), + (_c(r'Unable to deliver message to the following address\(es\)\.'), + _c(r'--- Original message follows\.'), + _c(r'<(?P[^>]*)>:')), # googlemail.com (_c('Delivery to the following recipient(s)? failed'), _c('----- Original message -----'), - _c('^\s*(?P[^\s@]+@[^\s@]+)\s*$')), + _c(r'^\s*(?P[^\s@]+@[^\s@]+)\s*$')), # kundenserver.de, mxlogic.net (_c('A message that you( have)? sent could not be delivered'), _c('^---'), - _c('<(?P[^>]*)>')), + _c(r'<(?P[^>]*)>')), # another kundenserver.de (_c('A message that you( have)? sent could not be delivered'), _c('^---'), - _c('^(?P[^\s@]+@[^\s@:]+):')), + _c(r'^(?P[^\s@]+@[^\s@:]+):')), # thehartford.com and amenworld.com (_c('Del(i|e)very to the following recipient(s)? (failed|was aborted)'), # this one may or may not have the original message, but there's nothing # unique to stop on, so stop on the first line of at least 3 characters # that doesn't start with 'D' (to not stop immediately) and has no '@'. - _c('^[^D][^@]{2,}$'), - _c('^\s*(. )?(?P[^\s@]+@[^\s@]+)\s*$')), + _c(r'^[^D][^@]{2,}$'), + _c(r'^\s*(. )?(?P[^\s@]+@[^\s@]+)\s*$')), # and another thehartfod.com/hartfordlife.com - (_c('^Your message\s*$'), + (_c(r'^Your message\s*$'), _c('^because:'), - _c('^\s*(?P[^\s@]+@[^\s@]+)\s*$')), + _c(r'^\s*(?P[^\s@]+@[^\s@]+)\s*$')), # kviv.be (InterScan NT) (_c('^Unable to deliver message to'), _c(r'\*+\s+End of message\s+\*+'), - _c('<(?P[^>]*)>')), + _c(r'<(?P[^>]*)>')), # earthlink.net supported domains (_c('^Sorry, unable to deliver your message to'), _c('^A copy of the original message'), - _c('\s*(?P[^\s@]+@[^\s@]+)\s+')), + _c(r'\s*(?P[^\s@]+@[^\s@]+)\s+')), # ademe.fr (_c('^A message could not be delivered to:'), _c('^Subject:'), - _c('^\s*(?P[^\s@]+@[^\s@]+)\s*$')), + _c(r'^\s*(?P[^\s@]+@[^\s@]+)\s*$')), # andrew.ac.jp (_c('^Invalid final delivery userid:'), _c('^Original message follows.'), - _c('\s*(?P[^\s@]+@[^\s@]+)\s*$')), + _c(r'\s*(?P[^\s@]+@[^\s@]+)\s*$')), # E500_SMTP_Mail_Service@lerctr.org and similar (_c('---- Failed Recipients ----'), _c(' Mail ----'), @@ -136,65 +136,65 @@ def _c(pattern): # cynergycom.net (_c('A message that you sent could not be delivered'), _c('^---'), - _c('(?P[^\s@]+@[^\s@)]+)')), + _c(r'(?P[^\s@]+@[^\s@)]+)')), # LSMTP for Windows - (_c('^--> Error description:\s*$'), + (_c(r'^--> Error description:\s*$'), _c('^Error-End:'), - _c('^Error-for:\s+(?P[^\s@]+@[^\s@]+)')), + _c(r'^Error-for:\s+(?P[^\s@]+@[^\s@]+)')), # Qmail with a tri-language intro beginning in spanish (_c('Your message could not be delivered'), _c('^-'), _c('<(?P[^>]*)>:')), # socgen.com (_c('Your message could not be delivered to'), - _c('^\s*$'), - _c('(?P[^\s@]+@[^\s@]+)')), + _c(r'^\s*$'), + _c(r'(?P[^\s@]+@[^\s@]+)')), # dadoservice.it (_c('Your message has encountered delivery problems'), _c('Your message reads'), - _c('addressed to\s*(?P[^\s@]+@[^\s@)]+)')), + _c(r'addressed to\s*(?P[^\s@]+@[^\s@)]+)')), # gomaps.com (_c('Did not reach the following recipient'), - _c('^\s*$'), - _c('\s(?P[^\s@]+@[^\s@]+)')), + _c(r'^\s*$'), + _c(r'\s(?P[^\s@]+@[^\s@]+)')), # EYOU MTA SYSTEM (_c('This is the deliver program at'), _c('^-'), - _c('^(?P[^\s@]+@[^\s@<>]+)')), + _c(r'^(?P[^\s@]+@[^\s@<>]+)')), # A non-standard qmail at ieo.it (_c('this is the email server at'), _c('^-'), - _c('\s(?P[^\s@]+@[^\s@]+)[\s,]')), + _c(r'\s(?P[^\s@]+@[^\s@]+)[\s,]')), # pla.net.py (MDaemon.PRO ?) (_c('- no such user here'), _c('There is no user'), - _c('^(?P[^\s@]+@[^\s@]+)\s')), + _c(r'^(?P[^\s@]+@[^\s@]+)\s')), # fastdnsservers.com (_c('The following recipient.*could not be reached'), _c('bogus stop pattern'), - _c('^(?P[^\s@]+@[^\s@]+)\s*$')), + _c(r'^(?P[^\s@]+@[^\s@]+)\s*$')), # lttf.com (_c('Could not deliver message to'), - _c('^\s*--'), - _c('^Failed Recipient:\s*(?P[^\s@]+@[^\s@]+)\s*$')), + _c(r'^\s*--'), + _c(r'^Failed Recipient:\s*(?P[^\s@]+@[^\s@]+)\s*$')), # uci.edu (_c('--------Message not delivered'), _c('--------Error Detail'), - _c('^\s*(?P[^\s@]+@[^\s@]+)\s*$')), + _c(r'^\s*(?P[^\s@]+@[^\s@]+)\s*$')), # Dovecot LDA Over quota MDN (bogus - should be DSN). (_c('^Your message'), _c('^Reporting'), _c( - 'Your message to (?P[^\s@]+@[^\s@]+) was automatically rejected' + r'Your message to (?P[^\s@]+@[^\s@]+) was automatically rejected' )), # mail.ru (_c('A message that you sent was rejected'), _c('This is a copy of your message'), - _c('\s(?P[^\s@]+@[^\s@]+)')), + _c(r'\s(?P[^\s@]+@[^\s@]+)')), # MailEnable (_c('Message could not be delivered to some recipients.'), _c('Message headers follow'), - _c('Recipient: \[SMTP:(?P[^\s@]+@[^\s@]+)\]')), + _c(r'Recipient: \[SMTP:(?P[^\s@]+@[^\s@]+)\]')), # This one is from Yahoo but dosen't fit the yahoo recognizer format (_c(r'wasn\'t able to deliver the following message'), _c(r'---Below this line is a copy of the message.'), diff --git a/Mailman/Handlers/CookHeaders.py b/Mailman/Handlers/CookHeaders.py index 4c6b0dac..85e51271 100644 --- a/Mailman/Handlers/CookHeaders.py +++ b/Mailman/Handlers/CookHeaders.py @@ -183,7 +183,7 @@ def process(mlist, msg, msgdata): uvia = str(via, lcs, errors='replace') # Replace the dummy replacements. - uvia = re.sub(u'%\(lrn\)s', ulrn, re.sub(u'%\(realname\)s', urn, uvia)) + uvia = re.sub(r'%\(lrn\)s', ulrn, re.sub(r'%\(realname\)s', urn, uvia)) # And get an RFC 2047 encoded header string. dn = str(Header(uvia, lcs)) change_header('From', @@ -424,7 +424,7 @@ def prefix_subject(mlist, msg, msgdata): # leading space after stripping the prefix. It is not known what MUA would # create such a Subject:, but the issue was reported. rematch = re.match( - '(\s*(RE|AW|SV|VS)\s*(\[\d+\])?\s*:\s*)+', + r'(\s*(RE|AW|SV|VS)\s*(\[\d+\])?\s*:\s*)+', subject, re.I) if rematch: subject = subject[rematch.end():] diff --git a/Mailman/Handlers/SpamDetect.py b/Mailman/Handlers/SpamDetect.py index 1c930cd2..a9e872fe 100644 --- a/Mailman/Handlers/SpamDetect.py +++ b/Mailman/Handlers/SpamDetect.py @@ -74,7 +74,7 @@ def getDecodedHeaders(msg, cset='utf-8'): uvalue = u'' try: if isinstance(v, str): - v = decode_header(re.sub('\n\s', ' ', v)) + v = decode_header(re.sub(r'\n\s', ' ', v)) else: continue except HeaderParseError: diff --git a/Mailman/Utils.py b/Mailman/Utils.py index 04e067df..5e722310 100644 --- a/Mailman/Utils.py +++ b/Mailman/Utils.py @@ -1530,7 +1530,7 @@ def check_eq_domains(email, domains_list): except ValueError: return [] domain = domain.lower() - domains_list = re.sub('\s', '', domains_list).lower() + domains_list = re.sub(r'\s', '', domains_list).lower() domains = domains_list.split(';') domains_list = [] for d in domains: diff --git a/bin/newlist b/bin/newlist index eeab3eb3..29ecfdbb 100755 --- a/bin/newlist +++ b/bin/newlist @@ -241,7 +241,7 @@ def main(): # And send the notice to the list owner if not quiet and not automate: - print('Hit enter to notify %(listname)s owner...'), + print(C_('Hit enter to notify %(listname)s owner...')), sys.stdin.readline() if not quiet: siteowner = Utils.get_site_email(mlist.host_name, 'owner')