Skip to content

Correctly identify signature if that is all that is in email #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions email_reply_parser.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions lib/email_reply_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ def quote_header?(line)
#
def finish_fragment
if @fragment
# Hit if there is an empty body above signature
if [email protected]? && SIG_REGEX.match(@fragment.lines.last)
@fragment.signature = true
end
@fragment.finish
if !@found_visible
if @fragment.quoted? || @fragment.signature? ||
Expand Down
11 changes: 11 additions & 0 deletions test/email_reply_parser_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions test/emails/only_sig.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--
202-555-1212