|
| 1 | +# -*- coding: utf-8 -*- |
1 | 2 | # |
2 | 3 | # Copyright (c) 2001 Bizar Software Pty Ltd (http://www.bizarsoftware.com.au/) |
3 | 4 | # This module is free software, and you may redistribute it and/or modify |
@@ -72,7 +73,7 @@ class node. Any parts of other types are each stored in separate files |
72 | 73 | an exception, the original message is bounced back to the sender with the |
73 | 74 | explanatory message given in the exception. |
74 | 75 |
|
75 | | -$Id: mailgw.py,v 1.184 2007-02-15 03:09:53 richard Exp $ |
| 76 | +$Id: mailgw.py,v 1.185 2007-03-26 04:04:42 richard Exp $ |
76 | 77 | """ |
77 | 78 | __docformat__ = 'restructuredtext' |
78 | 79 |
|
@@ -635,11 +636,14 @@ def handle_message(self, message): |
635 | 636 | 'argswhole']) |
636 | 637 |
|
637 | 638 | # Look for Re: et. al. Used later on for MAILGW_SUBJECT_CONTENT_MATCH |
638 | | - re_re = r'''(?P<refwd>(\s*\W?\s*(fw|fwd|re|aw|sv|ang)\W)+)\s*''' |
639 | | - m = re.match(re_re, tmpsubject, re.IGNORECASE|re.VERBOSE) |
| 639 | + refwd_re = config['MAILGW_REFWD_RE'].decode('iso8859-1') |
| 640 | + re_re = r'''(?P<refwd>%s)*\s*''' % refwd_re |
| 641 | + m = re.match(re_re, tmpsubject, re.IGNORECASE|re.VERBOSE|re.UNICODE) |
640 | 642 | if m: |
641 | | - matches.update(m.groupdict()) |
642 | | - tmpsubject = tmpsubject[len(matches['refwd']):] # Consume Re: |
| 643 | + m = m.groupdict() |
| 644 | + if m['refwd']: |
| 645 | + matches.update(m) |
| 646 | + tmpsubject = tmpsubject[len(m['refwd']):] # Consume Re: |
643 | 647 |
|
644 | 648 | # Look for Leading " |
645 | 649 | m = re.match(r'(?P<quote>\s*")', tmpsubject, |
@@ -1005,10 +1009,14 @@ def handle_message(self, message): |
1005 | 1009 | # figure how much we should muck around with the email body |
1006 | 1010 | keep_citations = config['MAILGW_KEEP_QUOTED_TEXT'] |
1007 | 1011 | keep_body = config['MAILGW_LEAVE_BODY_UNCHANGED'] |
| 1012 | + blank_line = re.compile(r'%s' % config['MAILGW_BLANKLINE_RE']) |
| 1013 | + eol = re.compile(r'%s' % config['MAILGW_EOL_RE']) |
| 1014 | + signature = re.compile(r'%s' % config['MAILGW_SIGN_RE']) |
| 1015 | + original_msg = re.compile(r'%s' % config['MAILGW_ORIGMSG_RE']) |
1008 | 1016 |
|
1009 | 1017 | # parse the body of the message, stripping out bits as appropriate |
1010 | 1018 | summary, content = parseContent(content, keep_citations, |
1011 | | - keep_body) |
| 1019 | + keep_body, blank_line, eol, signature, original_msg) |
1012 | 1020 | content = content.strip() |
1013 | 1021 |
|
1014 | 1022 | # |
@@ -1209,12 +1217,7 @@ def uidFromAddress(db, address, create=1, **user_props): |
1209 | 1217 | else: |
1210 | 1218 | return 0 |
1211 | 1219 |
|
1212 | | - |
1213 | | -def parseContent(content, keep_citations, keep_body, |
1214 | | - blank_line=re.compile(r'[\r\n]+\s*[\r\n]+'), |
1215 | | - eol=re.compile(r'[\r\n]+'), |
1216 | | - signature=re.compile(r'^[>|\s]*-- ?$'), |
1217 | | - original_msg=re.compile(r'^[>|\s]*-----\s?Original Message\s?-----$')): |
| 1220 | +def parseContent(content, keep_citations, keep_body, blank_line, eol, signature, original_msg): |
1218 | 1221 | ''' The message body is divided into sections by blank lines. |
1219 | 1222 | Sections where the second and all subsequent lines begin with a ">" |
1220 | 1223 | or "|" character are considered "quoting sections". The first line of |
|
0 commit comments