Skip to content

Commit 4b6fde4

Browse files
author
Roche Compaan
committed
stripping of email message body can be controlled through config variables...
...EMAIL_KEEP_QUOTED_TEST and EMAIL_LEAVE_BODY_UNCHANGED.
1 parent c18f098 commit 4b6fde4

File tree

4 files changed

+42
-10
lines changed

4 files changed

+42
-10
lines changed

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ Feature:
1919
<br>View: <display call="link('superseder', showid=1)">
2020
</property>
2121
</td>
22+
. stripping of the email message body can now be controlled through the
23+
config variables EMAIL_KEEP_QUOTED_TEXT and EMAIL_LEAVE_BODY_UNCHANGED.
2224

2325
Fixed:
2426
. stop sending blank (whitespace-only) notes

roundup/mailgw.py

Lines changed: 20 additions & 8 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.66 2002-03-14 23:59:24 richard Exp $
76+
$Id: mailgw.py,v 1.67 2002-04-23 15:46:49 rochecompaan Exp $
7777
'''
7878

7979

@@ -597,7 +597,10 @@ def handle_message(self, message):
597597
else:
598598
content = self.get_part_data_decoded(message)
599599

600-
summary, content = parseContent(content)
600+
keep_citations = self.instance.EMAIL_KEEP_QUOTED_TEXT == 'yes'
601+
keep_body = self.instance.EMAIL_LEAVE_BODY_UNCHANGED == 'yes'
602+
summary, content = parseContent(content, keep_citations,
603+
keep_body)
601604

602605
#
603606
# handle the attachments
@@ -745,8 +748,10 @@ def handle_message(self, message):
745748
# commit the new node(s) to the DB
746749
self.db.commit()
747750

748-
def parseContent(content, blank_line=re.compile(r'[\r\n]+\s*[\r\n]+'),
749-
eol=re.compile(r'[\r\n]+'), signature=re.compile(r'^[>|\s]*[-_]+\s*$')):
751+
def parseContent(content, keep_citations, keep_body,
752+
blank_line=re.compile(r'[\r\n]+\s*[\r\n]+'),
753+
eol=re.compile(r'[\r\n]+'),
754+
signature=re.compile(r'^[>|\s]*[-_]+\s*$')):
750755
''' The message body is divided into sections by blank lines.
751756
Sections where the second and all subsequent lines begin with a ">" or "|"
752757
character are considered "quoting sections". The first line of the first
@@ -778,9 +783,9 @@ def parseContent(content, blank_line=re.compile(r'[\r\n]+\s*[\r\n]+'),
778783
if line[0] not in '>|':
779784
break
780785
else:
781-
# TODO: people who want to keep quoted bits will want the
782-
# next line...
783-
# l.append(section)
786+
# we keep quoted bits if specified in the config
787+
if keep_citations:
788+
l.append(section)
784789
continue
785790
# keep this section - it has reponse stuff in it
786791
if not summary:
@@ -799,10 +804,17 @@ def parseContent(content, blank_line=re.compile(r'[\r\n]+\s*[\r\n]+'),
799804

800805
# and add the section to the output
801806
l.append(section)
802-
return summary, '\n\n'.join(l)
807+
# we only set content for those who want to delete cruft from the
808+
# message body, otherwise the body is left untouched.
809+
if not keep_body:
810+
content = '\n\n'.join(l)
811+
return summary, content
803812

804813
#
805814
# $Log: not supported by cvs2svn $
815+
# Revision 1.66 2002/03/14 23:59:24 richard
816+
# . #517734 ] web header customisation is obscure
817+
#
806818
# Revision 1.65 2002/02/15 00:13:38 richard
807819
# . #503204 ] mailgw needs a default class
808820
# - partially done - the setting of additional properties can wait for a

roundup/templates/classic/instance_config.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: instance_config.py,v 1.13 2002-03-14 23:59:24 richard Exp $
18+
# $Id: instance_config.py,v 1.14 2002-04-23 15:46:49 rochecompaan Exp $
1919

2020
MAIL_DOMAIN=MAILHOST=HTTP_HOST=None
2121
HTTP_PORT=0
@@ -83,6 +83,12 @@
8383
# Where to place the email signature
8484
EMAIL_SIGNATURE_POSITION = 'bottom'
8585

86+
# Keep email citations
87+
EMAIL_KEEP_QUOTED_TEXT = 'no'
88+
89+
# Preserve the email body as is
90+
EMAIL_LEAVE_BODY_UNCHANGED = 'no'
91+
8692
# Default class to use in the mailgw if one isn't supplied in email
8793
# subjects. To disable, comment out the variable below or leave it blank.
8894
# Examples:
@@ -144,6 +150,9 @@
144150

145151
#
146152
# $Log: not supported by cvs2svn $
153+
# Revision 1.13 2002/03/14 23:59:24 richard
154+
# . #517734 ] web header customisation is obscure
155+
#
147156
# Revision 1.12 2002/02/15 00:13:38 richard
148157
# . #503204 ] mailgw needs a default class
149158
# - partially done - the setting of additional properties can wait for a

roundup/templates/extended/instance_config.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: instance_config.py,v 1.13 2002-03-14 23:59:24 richard Exp $
18+
# $Id: instance_config.py,v 1.14 2002-04-23 15:46:49 rochecompaan Exp $
1919

2020
MAIL_DOMAIN=MAILHOST=HTTP_HOST=None
2121
HTTP_PORT=0
@@ -83,6 +83,12 @@
8383
# Where to place the email signature
8484
EMAIL_SIGNATURE_POSITION = 'bottom'
8585

86+
# Keep email citations
87+
EMAIL_KEEP_QUOTED_TEXT = 'no'
88+
89+
# Preserve the email body as is
90+
EMAIL_LEAVE_BODY_UNCHANGED = 'no'
91+
8692
# Default class to use in the mailgw if one isn't supplied in email
8793
# subjects. To disable, comment out the variable below or leave it blank.
8894
# Examples:
@@ -181,6 +187,9 @@
181187

182188
#
183189
# $Log: not supported by cvs2svn $
190+
# Revision 1.13 2002/03/14 23:59:24 richard
191+
# . #517734 ] web header customisation is obscure
192+
#
184193
# Revision 1.12 2002/02/15 00:13:38 richard
185194
# . #503204 ] mailgw needs a default class
186195
# - partially done - the setting of additional properties can wait for a

0 commit comments

Comments
 (0)