Skip to content

Commit 864bb81

Browse files
author
Richard Jones
committed
handle stupid mailers quoting subject lines
1 parent a17f700 commit 864bb81

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

roundup/mailgw.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class node. Any parts of other types are each stored in separate files
7373
an exception, the original message is bounced back to the sender with the
7474
explanatory message given in the exception.
7575
76-
$Id: mailgw.py,v 1.90 2002-09-25 05:13:34 richard Exp $
76+
$Id: mailgw.py,v 1.91 2002-09-26 00:01:51 richard Exp $
7777
'''
7878

7979
import string, re, os, mimetools, cStringIO, smtplib, socket, binascii, quopri
@@ -131,8 +131,8 @@ def getPart(self):
131131
return Message(s)
132132

133133
subject_re = re.compile(r'(?P<refwd>\s*\W?\s*(fwd|re|aw)\s*\W?\s*)*'
134-
r'\s*(\[(?P<classname>[^\d\s]+)(?P<nodeid>\d+)?\])?'
135-
r'\s*(?P<title>[^[]+)?(\[(?P<args>.+?)\])?', re.I)
134+
r'\s*(P<quote>")?(\[(?P<classname>[^\d\s]+)(?P<nodeid>\d+)?\])?'
135+
r'\s*(?P<title>[^[]+)?"?(\[(?P<args>.+?)\])?', re.I)
136136

137137
class MailGW:
138138
def __init__(self, instance, db):
@@ -435,6 +435,11 @@ def handle_message(self, message):
435435
else:
436436
title = ''
437437

438+
# strip off the quotes that dumb emailers put around the subject, like
439+
# Re: "[issue1] bla blah"
440+
if m.group('quote') and title.endswith('"'):
441+
title = title[:-1]
442+
438443
# but we do need either a title or a nodeid...
439444
if nodeid is None and not title:
440445
raise MailUsageError, '''

0 commit comments

Comments
 (0)