From be9f9fc3f5e7b684d849279765ffd048d3a87c55 Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Wed, 18 Dec 2013 18:21:21 -0300 Subject: added one more email quote separator --- askbot/mail/parsing.py | 59 ++++++++++++++++++++++++++++++++++++- askbot/tests/email_parsing_tests.py | 16 ++++++++++ 2 files changed, 74 insertions(+), 1 deletion(-) diff --git a/askbot/mail/parsing.py b/askbot/mail/parsing.py index 701d8063..2a9e9838 100644 --- a/askbot/mail/parsing.py +++ b/askbot/mail/parsing.py @@ -23,6 +23,8 @@ QUOTE_REGEXES = ( r'_+\nFrom:.*?\nSent:.*?\nTo:.*?\nSubject:.*?\Z', #OUTLOOK1 r'\n-+[\w -]+\nFrom:.*?\nSent:.*?\nTo:.*?\nSubject:.*?\Z', + #unknown + r'\n-+[\w -]+\nFrom:.*?\nDate:.*?\nTo:.*?\nSubject:.*?\Z', #YAHOO_QUOTE_RE = r'\n_+\n\s*From: [^\n]+\nTo: [^\n]+\nSent: [^\n]+\nSubject: [^\n]+\Z', #KMAIL_QUOTE_RE = @@ -31,10 +33,11 @@ QUOTE_REGEXES = ( r'\nSubject: [^\n]+\nFrom: [^\n]+\nTo: [^\n]+\nDate: [^\n]+\Z', #OUTLOOK_TEXT_QUOTE_RE = r'\n_+\Z', + r'From:.*?\nSent:.*?\nTo:.*?\nSubject:.*?\Z', ) -# extra samples +# extra samples, separated with #### """ -----Original Message-----^M From: forum@example.com [mailto:forum@example.com] ^M @@ -42,6 +45,60 @@ Sent: Wednesday, August 07, 2013 11:00 AM^M To: Jane Doe^M Subject: "One more test question from email."^M +########## + +________________________________ + From: "nobody@example.com" +To: fadeev@rocketmail.com +Sent: Wednesday, April 24, 2013 3:37 AM +Subject: Welcome to Askbot + +########## + +On Wed, Jul 3, 2013 at 10:40 AM, wrote: + +> ** +> Evgeny, please reply to this message. +> +> Your post could not be published, because we could not detect signature in +> your email. +> This happened either because this is your first post or you have changed +> your email signature. +> Please make a simple response, without editing this message. +> We will then attempt to detect the signature in your response and you +> should be able to post. +> ------------------------------ +> +> Sincerely, +> Gigaspaces XAP forum Administrator +> +> welcome-gofrnegwnwxgl9@example.org +> + + + +-- +Askbot +Valparaiso, Chile +skype: evgeny-fadeev + +############ +Test from email + +From: ask@ask.example.org [mailto:ask@ask.example.org] +Sent: Wednesday, July 03, 2013 10:41 AM +To: John Doe +Subject: aou aoeu oau aoeu aou aoeu oeau + +############ + + +-------- Original message -------- +From: forum@ask.examle.org +Date:12/15/2013 2:35 AM (GMT-05:00) +To: John Doe +Subject: this is it + """ diff --git a/askbot/tests/email_parsing_tests.py b/askbot/tests/email_parsing_tests.py index b87bbebe..10a0e194 100644 --- a/askbot/tests/email_parsing_tests.py +++ b/askbot/tests/email_parsing_tests.py @@ -63,6 +63,22 @@ Subject: "One more test question from email." """ self.assertEqual(mail.extract_reply(text), "some real text") + def test_some_other(self): + text = """some real text + +-------- Original message -------- +From: forum@example.com [mailto:forum@example.com] +Sent: Wednesday, August 07, 2013 11:00 AM +To: Jane Doe +Subject: "One more test question from email." + +""" + self.assertEqual(mail.extract_reply(text), "some real text") + + def test_some_other1(self): + text = 'some text here\n\n\n-------- Original message --------\nFrom: forum@example.com\nDate:12/15/2013 2:35 AM (GMT-05:00)\nTo: Some One\nSubject: some subject\n\n\n\n' + self.assertEqual(mail.extract_reply(text), 'some text here') + def test_blackberry(self): text = """Lorem ipsum lorem ipsum -- cgit v1.2.3-1-g7c22