Opened 16 years ago

Closed 15 years ago

#6 closed enhancement (fixed)

Strip email quotes

Reported by: trac@… Owned by: bas
Priority: major Milestone:
Component: email2trac Version: 0.1
Keywords: Cc: nicolasm@…


Is is possible to have email2trac automatically strip quotes from the email when updating? this will allow users to append a new comment to the ticket by pressing the reply (without cleaning the email body first).

Attachments (0)

Change History (13)

comment:1 Changed 16 years ago by bas

That feature will be a nice feature. If we add if we must make it configurable option.

comment:2 Changed 16 years ago by anonymous

I've made a patch for that feature. Feel free to add it to main branch.

config options:

strip_quotes: <int> (default: 0) mail_quote: <quote chars> (default: "> ")

diff -u /usr/local/src/email2trac-0.10/debian/email2trac/usr/bin/email2trac /usr/bin/email2trac 
--- /usr/local/src/email2trac-0.10/debian/email2trac/usr/bin/email2trac 2007-08-13 00:21:12.000000000 +0000
+++ /usr/bin/email2trac 2007-10-05 20:45:38.000000000 +0000
@@ -164,6 +164,11 @@
                if parameters.has_key('email_comment'):
                        self.comment = str(parameters['email_comment'])
+               if parameters.has_key('email_quote'):
+                       self.quote = str(parameters['email_quote'])
+                else:
+                        self.quote = '> '
                if parameters.has_key('email_header'):
                        self.EMAIL_HEADER = int(parameters['email_header'])
@@ -199,6 +204,11 @@
                        self.STRIP_SIGNATURE = 0
+               if parameters.has_key('strip_quotes'):
+                       self.STRIP_QUOTES = int(parameters['strip_quotes'])
+               else:
+                       self.STRIP_QUOTES = 0
                if parameters.has_key('use_textwrap'):
                        self.USE_TEXTWRAP = int(parameters['use_textwrap'])
@@ -677,6 +687,18 @@
                return ('\n'.join(body))
+       def strip_quotes(self, text):
+               """
+               Strip quotes from message by Nicolas Mendoza
+               """
+               body = []
+               for line in text.splitlines():
+                       if line.startswith(self.comment):
+                               continue
+                       body.append(line)
+               return ('\n'.join(body))
        def wrap_text(self, text, replace_whitespace = False):
@@ -728,6 +750,9 @@
                                if self.STRIP_SIGNATURE:
                                        body_text = self.strip_signature(body_text)
+                               if self.STRIP_QUOTES:
+                                       body_text = self.strip_quotes(body_text)
                                if self.USE_TEXTWRAP:
                                        body_text = self.wrap_text(body_text)

comment:3 Changed 16 years ago by nicolasm@…

Oh these came out wrong, and you can reach at the mail address I just used.

strip_quotes: <int> (default: 0)

mail_quote: <quote chars> (default: "> ")

comment:4 Changed 16 years ago by anonymous

  • Cc nicolasm@… added

comment:5 Changed 16 years ago by anonymous


email_quote: <quote chars> (default: "> ")

comment:6 Changed 16 years ago by bas

  • Status changed from new to assigned

Thanks for the patch, I will add it to the trunk version. Now we must definethe quote character there is no way to determine the quote character automatically?

comment:7 Changed 16 years ago by anonymous

There probably is some ways, you might want to check some RFCs for the default and add some extra heuristics for more exotic variations like: "NM> ", ">>* " etc.. maybe this: 4.5

comment:8 Changed 16 years ago by bas

Thanks for the info. If somebody wants to submit a update patch. I will appreciate it ;-)

comment:9 Changed 16 years ago by bas

There is ane email_quote defined but you use email.comment in your patch. Must that also be:


replaced by


comment:10 Changed 16 years ago by bas

Added to trunk version

comment:11 Changed 16 years ago by bas

  • Version changed from 0.9 to 0.1

comment:12 Changed 16 years ago by nicolasm@…

bas: you are right, sorry.

comment:13 Changed 15 years ago by anonymous

  • Resolution set to fixed
  • Status changed from assigned to closed

This is fixed in new version. That will be released soon.

Add Comment

Modify Ticket

Change Properties
as closed The owner will remain bas.
The resolution will be deleted. Next status will be 'reopened'.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.