diff --git a/lib/email_reply_parser.rb b/lib/email_reply_parser.rb index fecb313..d003af8 100644 --- a/lib/email_reply_parser.rb +++ b/lib/email_reply_parser.rb @@ -159,7 +159,7 @@ def scan_line(line) # Mark the current Fragment as a signature if the current line is empty # and the Fragment starts with a common signature indicator. - if @fragment && line == EMPTY + if @fragment && (is_quoted || line == EMPTY) if SIG_REGEX.match @fragment.lines.last @fragment.signature = true finish_fragment diff --git a/test/email_reply_parser_test.rb b/test/email_reply_parser_test.rb index e856974..39f6d65 100644 --- a/test/email_reply_parser_test.rb +++ b/test/email_reply_parser_test.rb @@ -180,6 +180,15 @@ def test_do_not_parse_out_send_from_in_regular_sentence assert_equal "Here is another email\n\nSent from my desk, is much easier then my mobile phone.", EmailReplyParser.parse_reply(body) end + def test_parse_sent_from_inbox + reply = email(:email_sent_from_inbox) + assert_equal [false, false, true], + reply.fragments.map { |f| f.signature? } + assert_equal [false, true, true], + reply.fragments.map { |f| f.hidden? } + assert_equal "Hi,\nThis is a test reply from Inbox.", reply.visible_text + end + def test_retains_bullets body = IO.read EMAIL_FIXTURE_PATH.join("email_bullets.txt").to_s assert_equal "test 2 this should list second\n\nand have spaces\n\nand retain this formatting\n\n\n - how about bullets\n - and another", diff --git a/test/emails/email_sent_from_inbox.txt b/test/emails/email_sent_from_inbox.txt new file mode 100644 index 0000000..f74242c --- /dev/null +++ b/test/emails/email_sent_from_inbox.txt @@ -0,0 +1,13 @@ +Hi, +This is a test reply from Inbox. + +On Wed, May 25, 2016 at 3:13 PM wrote: + +> LGTM +> +> — +> You are receiving this because you authored the thread. +> Reply to this email directly or view it on GitHub +> +-- +Hey there, this is my signature