diff options
-rw-r--r-- | askbot/mail/parsing.py | 57 | ||||
-rw-r--r-- | askbot/tests/email_parsing_tests.py | 16 |
2 files changed, 72 insertions, 1 deletions
diff --git a/askbot/mail/parsing.py b/askbot/mail/parsing.py index ffec3ecc..2a9e9838 100644 --- a/askbot/mail/parsing.py +++ b/askbot/mail/parsing.py @@ -33,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 @@ -44,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" <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, <ask@example.org> 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 |