Skip to content

Commit ca9c5a1

Browse files
committed
Improve signature delimiter regexp so that dashes/underscores/etc in the middle of text don't get interpreted as beginning of signature.
1 parent b501353 commit ca9c5a1

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

lib/email_reply_parser.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def read(text)
133133

134134
private
135135
EMPTY = "".freeze
136-
SIGNATURE = '(?m)(--|__|\w-$)|(^(\w+\s*){1,3} ym morf tneS$)'
136+
SIGNATURE = '(?m)^(--|__|\w-$)|(^(\w+\s*){1,3} ym morf tneS$)'
137137

138138
begin
139139
require 're2'

test/email_reply_parser_test.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,11 @@ def test_pathological_emails
167167
assert (Time.now - t0) < 1, "Took too long, upgrade to re2 gem."
168168
end
169169

170+
def test_doesnt_remove_signature_delimiter_in_mid_line
171+
reply = email(:email_sig_delimiter_in_middle_of_line)
172+
assert_equal 1, reply.fragments.size
173+
end
174+
170175
def email(name)
171176
body = IO.read EMAIL_FIXTURE_PATH.join("#{name}.txt").to_s
172177
EmailReplyParser.read body
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Hi there!
2+
3+
Stuff happened.
4+
5+
And here is a fix -- this is not a signature.
6+
7+
kthxbai

0 commit comments

Comments
 (0)