aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbwarsaw <>2005-05-13 02:34:39 +0000
committerbwarsaw <>2005-05-13 02:34:39 +0000
commit9dd0d69317e7144abbc410078a4d67b5701cef43 (patch)
treeaaa8e34974aaf3d0049f697e516ee7c2ef1dfbb4
parent7e13838af8d2975cb81e72d009d35b4f9cd111eb (diff)
downloadmailman2-9dd0d69317e7144abbc410078a4d67b5701cef43.tar.gz
mailman2-9dd0d69317e7144abbc410078a4d67b5701cef43.tar.xz
mailman2-9dd0d69317e7144abbc410078a4d67b5701cef43.zip
strip_subject() in HyperArch.py
prefix_subject() in CookHeaders.py When calling re.sub() to substitute the subject prefix, you have to escape the pattern, otherwise prefixes like [C++] cause "multiple repeat" exceptions in re. Also, whitespace normalization and copyright years updates.
-rw-r--r--Mailman/Archiver/HyperArch.py6
-rw-r--r--Mailman/Defaults.py.in10
-rw-r--r--Mailman/Handlers/CookHeaders.py15
3 files changed, 16 insertions, 15 deletions
diff --git a/Mailman/Archiver/HyperArch.py b/Mailman/Archiver/HyperArch.py
index 5a37adad..c6a2ff0e 100644
--- a/Mailman/Archiver/HyperArch.py
+++ b/Mailman/Archiver/HyperArch.py
@@ -1,4 +1,4 @@
-# Copyright (C) 1998-2003 by the Free Software Foundation, Inc.
+# Copyright (C) 1998-2005 by the Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -412,7 +412,7 @@ class Article(pipermail.Article):
if prefix:
prefix_pat = re.sub(r'%\d*d', r'\s*\d+\s*', prefix)
prefix_pat = re.sub('([\[\(\{\)])', '\\\\\g<1>', prefix_pat)
- subject = re.sub(prefix_pat, '', subject)
+ subject = re.sub(re.escape(prefix_pat), '', subject)
subject = subject.lstrip()
strip_pat = re.compile('^((RE|AW|SV)(\[\d+\])?:\s*)+', re.I)
stripped = strip_pat.sub('', subject)
@@ -585,7 +585,7 @@ class Article(pipermail.Article):
try:
del self.html_body
except AttributeError:
- pass
+ pass
class HyperArchive(pipermail.T):
diff --git a/Mailman/Defaults.py.in b/Mailman/Defaults.py.in
index 5ed516f8..dd73fc4e 100644
--- a/Mailman/Defaults.py.in
+++ b/Mailman/Defaults.py.in
@@ -829,12 +829,14 @@ DEFAULT_MSG_FOOTER = """_______________________________________________
"""
# Where to put subject prefix for 'Re:' messages:
+#
# old style: Re: [prefix] test
# new style: [prefix 123] Re: test ... (number is optional)
-# Old style is default for backward compatibility. New style is forced if
-# a list owner set %d (numbering) in prefix. If the site owner had applied
-# new style patch (from SF patch area) before, he/she may want to set this
-# No in mm_cfg.py.
+#
+# Old style is default for backward compatibility. New style is forced if a
+# list owner set %d (numbering) in prefix. If the site owner had applied new
+# style patch (from SF patch area) before, he/she may want to set this No in
+# mm_cfg.py.
OLD_STYLE_PREFIXING = Yes
# Scrub regular delivery
diff --git a/Mailman/Handlers/CookHeaders.py b/Mailman/Handlers/CookHeaders.py
index fce88c44..993c0471 100644
--- a/Mailman/Handlers/CookHeaders.py
+++ b/Mailman/Handlers/CookHeaders.py
@@ -1,4 +1,4 @@
-# Copyright (C) 1998-2004 by the Free Software Foundation, Inc.
+# Copyright (C) 1998-2005 by the Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -14,8 +14,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-"""Cook a message's Subject header.
-"""
+"""Cook a message's Subject header."""
from __future__ import nested_scopes
import re
@@ -51,7 +50,7 @@ nonascii = re.compile('[^\s!-~]')
def uheader(mlist, s, header_name=None, continuation_ws='\t', maxlinelen=None):
# Get the charset to encode the string in. Then search if there is any
- # non-ascii character is in the string. If there is and the charset is
+ # non-ascii character is in the string. If there is and the charset is
# us-ascii then we use iso-8859-1 instead. If the string is ascii only
# we use 'us-ascii' if another charset is specified.
charset = Utils.GetCharSet(mlist.preferred_language)
@@ -188,7 +187,7 @@ def process(mlist, msg, msgdata):
i18ndesc = uheader(mlist, mlist.description, 'List-Id', maxlinelen=998)
listid_h = formataddr((str(i18ndesc), listid))
else:
- # without desc we need to ensure the MUST brackets
+ # without desc we need to ensure the MUST brackets
listid_h = '<%s>' % listid
# We always add a List-ID: header.
del msg['list-id']
@@ -236,7 +235,7 @@ def prefix_subject(mlist, msg, msgdata):
# tracked (e.g. internally crafted, delivered to a single user such as the
# list admin).
prefix = mlist.subject_prefix.strip()
- if not prefix:
+ if not prefix:
return
subject = msg.get('subject', '')
# Try to figure out what the continuation_ws is for the header
@@ -260,7 +259,7 @@ def prefix_subject(mlist, msg, msgdata):
# [],(), or {}, the prefix in the responding post subject will be cared.
# sequential number format allows '%05d' like pattern.
p = re.compile('%\d*d')
- if p.search(prefix,1):
+ if p.search(prefix, 1):
# prefix have number, so we should search prefix w/number in subject.
# Also, old_style is forced to False
prefix_pattern = p.sub(r'\s*\d+\s*', prefix)
@@ -271,7 +270,7 @@ def prefix_subject(mlist, msg, msgdata):
# Convert [ ( { ) --> \\[ \\( \\{ \\) to feed into re module.
# TK: Something magic should be here but after trial and error...
prefix_pattern = re.sub('([\[\(\{\)])', '\\\\\g<1>', prefix_pattern)
- subject = re.sub(prefix_pattern, '', subject)
+ subject = re.sub(re.escape(prefix_pattern), '', subject)
rematch = re.match('((RE|AW|SV)(\[\d+\])?:\s*)+', subject, re.I)
if rematch:
subject = subject[rematch.end():]