diff --git a/email_reply_parser.gemspec b/email_reply_parser.gemspec index b883e00..ab71f16 100644 --- a/email_reply_parser.gemspec +++ b/email_reply_parser.gemspec @@ -71,6 +71,7 @@ Gem::Specification.new do |s| script/test test/email_reply_parser_test.rb test/emails/correct_sig.txt + test/emails/only_sig.txt test/emails/email_1_1.txt test/emails/email_1_2.txt test/emails/email_1_3.txt diff --git a/lib/email_reply_parser.rb b/lib/email_reply_parser.rb index 982eaec..3b4ad3c 100644 --- a/lib/email_reply_parser.rb +++ b/lib/email_reply_parser.rb @@ -216,6 +216,10 @@ def quote_header?(line) # def finish_fragment if @fragment + # Hit if there is an empty body above signature + if !@fragment.signature? && SIG_REGEX.match(@fragment.lines.last) + @fragment.signature = true + end @fragment.finish if !@found_visible if @fragment.quoted? || @fragment.signature? || diff --git a/test/email_reply_parser_test.rb b/test/email_reply_parser_test.rb index 6710838..847b910 100644 --- a/test/email_reply_parser_test.rb +++ b/test/email_reply_parser_test.rb @@ -107,6 +107,17 @@ def test_reads_email_with_correct_signature assert_match /^-- \nrick/, reply.fragments[1].to_s end + def test_reads_email_with_only_signature + reply = email :only_sig + + assert_equal 1, reply.fragments.size + assert_equal [false], reply.fragments.map { |f| f.quoted? } + assert_equal [true], reply.fragments.map { |f| f.signature? } + assert_equal [true], reply.fragments.map { |f| f.hidden? } + assert_match /^--\n202-555-1212\n/, reply.fragments[0].to_s + end + + def test_deals_with_multiline_reply_headers reply = email :email_1_6 diff --git a/test/emails/only_sig.txt b/test/emails/only_sig.txt new file mode 100644 index 0000000..f942f23 --- /dev/null +++ b/test/emails/only_sig.txt @@ -0,0 +1,2 @@ +-- +202-555-1212