From fcd9e2716a6553d1ec79842f8959027d2fdc44f0 Mon Sep 17 00:00:00 2001 From: Adam Renberg Date: Mon, 21 Sep 2015 21:33:55 +0200 Subject: [PATCH] Add fix for Apple Mail email format Where they have an initial > on the "date line". --- talon/quotations.py | 4 ++-- .../standard_replies/apple_mail_2.eml | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 tests/fixtures/standard_replies/apple_mail_2.eml diff --git a/talon/quotations.py b/talon/quotations.py index d699acd..010e20d 100644 --- a/talon/quotations.py +++ b/talon/quotations.py @@ -22,7 +22,7 @@ log = logging.getLogger(__name__) RE_FWD = re.compile("^[-]+[ ]*Forwarded message[ ]*[-]+$", re.I | re.M) RE_ON_DATE_SMB_WROTE = re.compile( - u'(-*[ ]?({0})[ ].*({1})(.*\n){{0,2}}.*({2}):?-*)'.format( + u'(-*[>]?[ ]?({0})[ ].*({1})(.*\n){{0,2}}.*({2}):?-*)'.format( # Beginning of the line u'|'.join(( # English @@ -59,7 +59,7 @@ RE_ON_DATE_SMB_WROTE = re.compile( )) # Special case for languages where text is translated like this: 'on {date} wrote {somebody}:' RE_ON_DATE_WROTE_SMB = re.compile( - u'(-*[ ]?({0})[ ].*(.*\n){{0,2}}.*({1})[ ]*.*:)'.format( + u'(-*[>]?[ ]?({0})[ ].*(.*\n){{0,2}}.*({1})[ ]*.*:)'.format( # Beginning of the line u'|'.join(( 'Op', diff --git a/tests/fixtures/standard_replies/apple_mail_2.eml b/tests/fixtures/standard_replies/apple_mail_2.eml new file mode 100644 index 0000000..a030311 --- /dev/null +++ b/tests/fixtures/standard_replies/apple_mail_2.eml @@ -0,0 +1,19 @@ +Content-Type: text/plain; + charset=us-ascii +Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\)) +Subject: Re: Hello there +X-Universally-Unique-Identifier: 85B1075D-5841-46A9-8565-FCB287A93AC4 +From: Adam Renberg +In-Reply-To: +Date: Sat, 22 Aug 2015 19:22:20 +0200 +Content-Transfer-Encoding: 7bit +X-Smtp-Server: smtp.gmail.com:adam@tictail.com +Message-Id: <68001B29-8EA4-444C-A894-0537D2CA5208@tictail.com> +References: +To: Adam Renberg + +Hello +> On 22 Aug 2015, at 19:21, Adam Renberg wrote: +> +> Hi there! +