From 404b86eea76542c834fef4a779846561bd5ae579 Mon Sep 17 00:00:00 2001 From: Ari Summer Date: Wed, 31 Dec 2014 22:04:08 -0700 Subject: [PATCH 1/2] Add From: phrase to email signature regex --- lib/email_reply_parser.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/email_reply_parser.rb b/lib/email_reply_parser.rb index 982eaec..acfbecc 100644 --- a/lib/email_reply_parser.rb +++ b/lib/email_reply_parser.rb @@ -133,7 +133,7 @@ def read(text) private EMPTY = "".freeze - SIGNATURE = '(?m)(--\s*$|__\s*$|\w-$)|(^(\w+\s*){1,3} ym morf tneS$)' + SIGNATURE = '(?m)(--\s*$|__\s*$|\w-$)|(^(\w+\s*){1,3} ym morf tneS$)|(.*:morF)' begin require 're2' From b0b16483f775c343b8dfbc6662a65cf756ee1698 Mon Sep 17 00:00:00 2001 From: Ari Summer Date: Thu, 1 Jan 2015 19:45:16 -0700 Subject: [PATCH 2/2] Add test case for outlook with no line below reply --- test/email_reply_parser_test.rb | 5 +++++ test/emails/email_2_3.txt | 8 ++++++++ 2 files changed, 13 insertions(+) create mode 100644 test/emails/email_2_3.txt diff --git a/test/email_reply_parser_test.rb b/test/email_reply_parser_test.rb index 6710838..2b16313 100644 --- a/test/email_reply_parser_test.rb +++ b/test/email_reply_parser_test.rb @@ -144,6 +144,11 @@ def test_parse_out_just_top_for_outlook_with_reply_directly_above_line assert_equal "Outlook with a reply directly above line", EmailReplyParser.parse_reply(body) end + def test_parse_out_just_top_for_outlook_with_no_line_below_reply + body = IO.read EMAIL_FIXTURE_PATH.join("email_2_3.txt").to_s + assert_equal "Outlook with no line below reply", EmailReplyParser.parse_reply(body) + end + def test_parse_out_sent_from_iPhone body = IO.read EMAIL_FIXTURE_PATH.join("email_iPhone.txt").to_s assert_equal "Here is another email", EmailReplyParser.parse_reply(body) diff --git a/test/emails/email_2_3.txt b/test/emails/email_2_3.txt new file mode 100644 index 0000000..3bbe7f8 --- /dev/null +++ b/test/emails/email_2_3.txt @@ -0,0 +1,8 @@ +Outlook with no line below reply + +From: CRM Comments [crm-comment@example.com] +Sent: Friday, 23 March 2012 5:08 p.m. +To: John S. Greene +Subject: [contact:106] John Greene + +I don't like putting lines above my signature!