From 999e9c3725b7ced46d1c2ed564f5e830a113ba14 Mon Sep 17 00:00:00 2001 From: Sergey Obukhov Date: Fri, 19 Feb 2016 17:53:52 -0800 Subject: [PATCH] fixes mailgun/talon#19 --- talon/quotations.py | 9 +++++++-- tests/text_quotations_test.py | 12 ++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/talon/quotations.py b/talon/quotations.py index a40d247..9ce3b25 100644 --- a/talon/quotations.py +++ b/talon/quotations.py @@ -137,11 +137,16 @@ RE_FROM_COLON_OR_DATE_COLON = re.compile(u'(_+\r?\n)?[\s]*(:?[*]?{})[\s]?:[*]? . SPLITTER_PATTERNS = [ RE_ORIGINAL_MESSAGE, - # - re.compile("(\d+/\d+/\d+|\d+\.\d+\.\d+).*@", re.S), RE_ON_DATE_SMB_WROTE, RE_ON_DATE_WROTE_SMB, RE_FROM_COLON_OR_DATE_COLON, + # 02.04.2012 14:20 пользователь "bob@example.com" < + # bob@xxx.mailgun.org> написал: + re.compile("(\d+/\d+/\d+|\d+\.\d+\.\d+).*@", re.S), + # 2014-10-17 11:28 GMT+03:00 Bob < + # bob@example.com>: + re.compile("\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}\s+GMT.*@", re.S), + # Thu, 26 Jun 2014 14:00:51 +0400 Bob : re.compile('\S{3,10}, \d\d? \S{3,10} 20\d\d,? \d\d?:\d\d(:\d\d)?' '( \S+){3,6}@\S+:') ] diff --git a/tests/text_quotations_test.py b/tests/text_quotations_test.py index ae481e1..a4655d9 100644 --- a/tests/text_quotations_test.py +++ b/tests/text_quotations_test.py @@ -54,6 +54,18 @@ On 04/19/2011 07:10 AM, Roman Tkachenko wrote: eq_("Test reply", quotations.extract_from_plain(msg_body)) +def test_date_time_email_splitter(): + msg_body = """Test reply + +2014-10-17 11:28 GMT+03:00 Postmaster < +postmaster@sandboxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.mailgun.org>: + +> First from site +> + """ + eq_("Test reply", quotations.extract_from_plain(msg_body)) + + def test_pattern_on_date_somebody_wrote_allows_space_in_front(): msg_body = """Thanks Thanmai On Mar 8, 2012 9:59 AM, "Example.com" <