Skip to content

Commit 49394b4

Browse files
committed
don't use such a greedy matcher
1 parent 2bdba4a commit 49394b4

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

lib/email_reply_parser.rb

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

8585
# Check for multi-line reply headers. Some clients break up
8686
# the "On DATE, NAME <EMAIL> wrote:" line into multiple lines.
87-
if text =~ /^(On\s(.+)wrote:)$/nm
87+
if text =~ /^(On\s(.+?)wrote:)$/nm
8888
# Remove all new lines from the reply header.
8989
text.gsub! $1, $1.gsub("\n", " ")
9090
end

test/email_reply_parser_test.rb

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,21 +65,22 @@ def test_reads_bottom_post
6565

6666
def test_reads_inline_replies
6767
reply = email(:email_1_8)
68-
assert_equal 6, reply.fragments.size
68+
assert_equal 7, reply.fragments.size
6969

70-
assert_equal [true, false, true, false, false, false],
70+
assert_equal [true, false, true, false, true, false, false],
7171
reply.fragments.map { |f| f.quoted? }
72-
assert_equal [false, false, false, false, false, true],
72+
assert_equal [false, false, false, false, false, false, true],
7373
reply.fragments.map { |f| f.signature? }
74-
assert_equal [false, false, false, false, true, true],
74+
assert_equal [false, false, false, false, true, true, true],
7575
reply.fragments.map { |f| f.hidden? }
7676

7777
assert_match /^On [^\:]+\:/, reply.fragments[0].to_s
7878
assert_match /^I will reply/, reply.fragments[1].to_s
79-
assert_match /^> /, reply.fragments[2].to_s
79+
assert_match "okay?", reply.fragments[2].to_s
8080
assert_match /^and under this./, reply.fragments[3].to_s
81-
assert_match /^> /, reply.fragments[4].to_s
82-
assert_match /^-/, reply.fragments[5].to_s
81+
assert_match /inline/, reply.fragments[4].to_s
82+
assert_equal "\n", reply.fragments[5].to_s
83+
assert_equal "--\nHey there, this is my signature\n", reply.fragments[6].to_s
8384
end
8485

8586
def test_recognizes_date_string_above_quote

0 commit comments

Comments
 (0)