aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortkikuchi <>2005-05-13 11:35:38 +0000
committertkikuchi <>2005-05-13 11:35:38 +0000
commit3932f79538d5ba4ff30964086ef9bc129091f154 (patch)
tree9dd104173a7f679e57863b1e4d5d0164066de8c3
parent264c89eee7d25b5ad439ef1f0304eb47ce9e7d84 (diff)
downloadmailman2-3932f79538d5ba4ff30964086ef9bc129091f154.tar.gz
mailman2-3932f79538d5ba4ff30964086ef9bc129091f154.tar.xz
mailman2-3932f79538d5ba4ff30964086ef9bc129091f154.zip
I finally find out why re.escape() doesn't work properly. '%' should not
be escaped for it is the insert directive. It was my trial and error in the comments in previous version. Well, I didn't think of '++' ...
-rw-r--r--Mailman/Archiver/HyperArch.py7
-rw-r--r--Mailman/Handlers/CookHeaders.py16
2 files changed, 12 insertions, 11 deletions
diff --git a/Mailman/Archiver/HyperArch.py b/Mailman/Archiver/HyperArch.py
index c6a2ff0e..372f2409 100644
--- a/Mailman/Archiver/HyperArch.py
+++ b/Mailman/Archiver/HyperArch.py
@@ -410,9 +410,10 @@ class Article(pipermail.Article):
# This part was taken from CookHeaders.py (TK)
prefix = self._mlist.subject_prefix.strip()
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(re.escape(prefix_pat), '', subject)
+ prefix_pat = re.escape(prefix)
+ prefix_pat = '%'.join(prefix_pat.split(r'\%'))
+ prefix_pat = re.sub(r'%\d*d', r'\s*\d+\s*', prefix_pat)
+ subject = re.sub(prefix_pat, '', subject)
subject = subject.lstrip()
strip_pat = re.compile('^((RE|AW|SV)(\[\d+\])?:\s*)+', re.I)
stripped = strip_pat.sub('', subject)
diff --git a/Mailman/Handlers/CookHeaders.py b/Mailman/Handlers/CookHeaders.py
index 6b81546e..1db23aec 100644
--- a/Mailman/Handlers/CookHeaders.py
+++ b/Mailman/Handlers/CookHeaders.py
@@ -253,21 +253,21 @@ def prefix_subject(mlist, msg, msgdata):
# subject is mime-encoded and cset is set as us-ascii. See detail
# for ch_oneline() (CookHeaders one line function).
subject, cset = ch_oneline(subject)
- # Note: searching prefix in subject is REMOVED. (seq version)
# If the subject_prefix contains '%d', it is replaced with the
- # mailing list sequential number. Also, if the prefix is closed with
- # [],(), or {}, the prefix in the responding post subject will be cared.
- # sequential number format allows '%05d' like pattern.
+ # mailing list sequential number. Sequential number format allows
+ # '%d' or '%05d' like pattern.
+ prefix_pattern = re.escape(prefix)
+ # unescape '%' :-<
+ prefix_pattern = '%'.join(prefix_pattern.split(r'\%'))
p = re.compile('%\d*d')
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)
+ # Also, force new style.
+ prefix_pattern = p.sub(r'\s*\d+\s*', prefix_pattern)
old_style = False
else:
- prefix_pattern = prefix
old_style = mm_cfg.OLD_STYLE_PREFIXING
- subject = re.sub(re.escape(prefix_pattern), '', subject)
+ subject = re.sub(prefix_pattern, '', subject)
rematch = re.match('((RE|AW|SV)(\[\d+\])?:\s*)+', subject, re.I)
if rematch:
subject = subject[rematch.end():]