@@ -73,15 +73,15 @@ class node. Any parts of other types are each stored in separate files
7373an exception, the original message is bounced back to the sender with the
7474explanatory message given in the exception.
7575
76- $Id: mailgw.py,v 1.186 2007-03-26 06:19:55 richard Exp $
76+ $Id: mailgw.py,v 1.187 2007-04-03 06:43:30 a1s Exp $
7777"""
7878__docformat__ = 'restructuredtext'
7979
8080import string , re , os , mimetools , cStringIO , smtplib , socket , binascii , quopri
8181import time , random , sys , logging
8282import traceback , MimeWriter , rfc822
8383
84- from roundup import hyperdb , date , password , rfc2822 , exceptions
84+ from roundup import configuration , hyperdb , date , password , rfc2822 , exceptions
8585from roundup .mailer import Mailer , MessageSendError
8686from roundup .i18n import _
8787
@@ -636,8 +636,7 @@ def handle_message(self, message):
636636 'argswhole' ])
637637
638638 # Look for Re: et. al. Used later on for MAILGW_SUBJECT_CONTENT_MATCH
639- refwd_re = config ['MAILGW_REFWD_RE' ].decode ('iso8859-1' )
640- re_re = r'''(?P<refwd>%s)*\s*''' % refwd_re
639+ re_re = r"(?P<refwd>%s)*\s*" % config ["MAILGW_REFWD_RE" ].pattern
641640 m = re .match (re_re , tmpsubject , re .IGNORECASE | re .VERBOSE | re .UNICODE )
642641 if m :
643642 m = m .groupdict ()
@@ -664,7 +663,7 @@ def handle_message(self, message):
664663 matches .update (m .groupdict ())
665664 # Skip to the end of the class identifier, including any
666665 # garbage before it.
667-
666+
668667 tmpsubject = tmpsubject [m .end ():]
669668
670669 # if we've not found a valid classname prefix then force the
@@ -1006,17 +1005,8 @@ def handle_message(self, message):
10061005not find a text/plain part to use.
10071006""" )
10081007
1009- # figure how much we should muck around with the email body
1010- keep_citations = config ['MAILGW_KEEP_QUOTED_TEXT' ]
1011- keep_body = config ['MAILGW_LEAVE_BODY_UNCHANGED' ]
1012- blank_line = re .compile (config ['MAILGW_BLANKLINE_RE' ])
1013- eol = re .compile (config ['MAILGW_EOL_RE' ])
1014- signature = re .compile (config ['MAILGW_SIGN_RE' ])
1015- original_msg = re .compile (config ['MAILGW_ORIGMSG_RE' ])
1016-
10171008 # parse the body of the message, stripping out bits as appropriate
1018- summary , content = parseContent (content , keep_citations ,
1019- keep_body , blank_line , eol , signature , original_msg )
1009+ summary , content = parseContent (content , config = config )
10201010 content = content .strip ()
10211011
10221012 #
@@ -1217,25 +1207,45 @@ def uidFromAddress(db, address, create=1, **user_props):
12171207 else :
12181208 return 0
12191209
1220- def parseContent (content , keep_citations , keep_body , blank_line , eol , signature , original_msg ):
1221- ''' The message body is divided into sections by blank lines.
1222- Sections where the second and all subsequent lines begin with a ">"
1223- or "|" character are considered "quoting sections". The first line of
1224- the first non-quoting section becomes the summary of the message.
1210+ def parseContent (content , keep_citations = None , keep_body = None , config = None ):
1211+ """Parse mail message; return message summary and stripped content
1212+
1213+ The message body is divided into sections by blank lines.
1214+ Sections where the second and all subsequent lines begin with a ">"
1215+ or "|" character are considered "quoting sections". The first line of
1216+ the first non-quoting section becomes the summary of the message.
1217+
1218+ Arguments:
1219+
1220+ keep_citations: declared for backward compatibility.
1221+ If omitted or None, use config["MAILGW_KEEP_QUOTED_TEXT"]
1222+
1223+ keep_body: declared for backward compatibility.
1224+ If omitted or None, use config["MAILGW_LEAVE_BODY_UNCHANGED"]
1225+
1226+ config: tracker configuration object.
1227+ If omitted or None, use default configuration.
1228+
1229+ """
1230+ if config is None :
1231+ config = configuration .CoreConfig ()
1232+ if keep_citations is None :
1233+ keep_citations = config ["MAILGW_KEEP_QUOTED_TEXT" ]
1234+ if keep_body is None :
1235+ keep_body = config ["MAILGW_LEAVE_BODY_UNCHANGED" ]
1236+ eol = config ["MAILGW_EOL_RE" ]
1237+ signature = config ["MAILGW_SIGN_RE" ]
1238+ original_msg = config ["MAILGW_ORIGMSG_RE" ]
12251239
1226- If keep_citations is true, then we keep the "quoting sections" in the
1227- content.
1228- If keep_body is true, we even keep the signature sections.
1229- '''
12301240 # strip off leading carriage-returns / newlines
12311241 i = 0
12321242 for i in range (len (content )):
12331243 if content [i ] not in '\r \n ' :
12341244 break
12351245 if i > 0 :
1236- sections = blank_line .split (content [i :])
1246+ sections = config [ "MAILGW_BLANKLINE_RE" ] .split (content [i :])
12371247 else :
1238- sections = blank_line .split (content )
1248+ sections = config [ "MAILGW_BLANKLINE_RE" ] .split (content )
12391249
12401250 # extract out the summary from the message
12411251 summary = ''
0 commit comments