Mercurial > p > roundup > code
comparison roundup/mailgw.py @ 1217:984c498e7deb
handle stupid mailers quoting subject lines
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Thu, 26 Sep 2002 00:01:51 +0000 |
| parents | e47d9bb1455b |
| children | 953279b8b32f |
comparison
equal
deleted
inserted
replaced
| 1216:9e7b2a54f862 | 1217:984c498e7deb |
|---|---|
| 71 set() method to add the message to the item's spool; in the second case we | 71 set() method to add the message to the item's spool; in the second case we |
| 72 are calling the create() method to create a new node). If an auditor raises | 72 are calling the create() method to create a new node). If an auditor raises |
| 73 an exception, the original message is bounced back to the sender with the | 73 an exception, the original message is bounced back to the sender with the |
| 74 explanatory message given in the exception. | 74 explanatory message given in the exception. |
| 75 | 75 |
| 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 $ |
| 77 ''' | 77 ''' |
| 78 | 78 |
| 79 import string, re, os, mimetools, cStringIO, smtplib, socket, binascii, quopri | 79 import string, re, os, mimetools, cStringIO, smtplib, socket, binascii, quopri |
| 80 import time, random, sys | 80 import time, random, sys |
| 81 import traceback, MimeWriter | 81 import traceback, MimeWriter |
| 129 return None | 129 return None |
| 130 s.seek(0) | 130 s.seek(0) |
| 131 return Message(s) | 131 return Message(s) |
| 132 | 132 |
| 133 subject_re = re.compile(r'(?P<refwd>\s*\W?\s*(fwd|re|aw)\s*\W?\s*)*' | 133 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+)?\])?' | 134 r'\s*(P<quote>")?(\[(?P<classname>[^\d\s]+)(?P<nodeid>\d+)?\])?' |
| 135 r'\s*(?P<title>[^[]+)?(\[(?P<args>.+?)\])?', re.I) | 135 r'\s*(?P<title>[^[]+)?"?(\[(?P<args>.+?)\])?', re.I) |
| 136 | 136 |
| 137 class MailGW: | 137 class MailGW: |
| 138 def __init__(self, instance, db): | 138 def __init__(self, instance, db): |
| 139 self.instance = instance | 139 self.instance = instance |
| 140 self.db = db | 140 self.db = db |
| 433 if title: | 433 if title: |
| 434 title = title.strip() | 434 title = title.strip() |
| 435 else: | 435 else: |
| 436 title = '' | 436 title = '' |
| 437 | 437 |
| 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 | |
| 438 # but we do need either a title or a nodeid... | 443 # but we do need either a title or a nodeid... |
| 439 if nodeid is None and not title: | 444 if nodeid is None and not title: |
| 440 raise MailUsageError, ''' | 445 raise MailUsageError, ''' |
| 441 I cannot match your message to a node in the database - you need to either | 446 I cannot match your message to a node in the database - you need to either |
| 442 supply a full node identifier (with number, eg "[issue123]" or keep the | 447 supply a full node identifier (with number, eg "[issue123]" or keep the |
