Skip to content

Commit 8d4f466

Browse files
committed
catch date strings above quoted regions when separated by a blank line
1 parent 65c7e14 commit 8d4f466

3 files changed

Lines changed: 16 additions & 2 deletions

File tree

lib/email_reply_parser.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def read(text)
7474
@fragment = nil
7575

7676
# Use the StringScanner to pull out each line of the email content.
77-
@scanner = StringScanner.new(text)
77+
@scanner = StringScanner.new(text)
7878
while line = @scanner.scan_until(/\n/)
7979
scan_line(line)
8080
end
@@ -129,7 +129,7 @@ def scan_line(line)
129129
# it doesn't start with `>`.
130130
if @fragment &&
131131
((@fragment.quoted? == is_quoted) ||
132-
(@fragment.quoted? && quote_header?(line)))
132+
(@fragment.quoted? && (quote_header?(line) || line == EMPTY)))
133133
@fragment.lines << line
134134

135135
# Otherwise, finish the fragment and start a new one.

test/email_reply_parser_test.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,15 @@ def test_reads_bottom_post
6363
assert_match /^_/, reply.fragments[5].to_s
6464
end
6565

66+
def test_recognizes_date_string_above_quote
67+
reply = email :email_1_4
68+
69+
assert_match /^Awesome/, reply.fragments[0].to_s
70+
assert_match /^On/, reply.fragments[1].to_s
71+
assert_match /Loader/, reply.fragments[1].to_s
72+
puts reply.fragments[1].to_s.inspect
73+
end
74+
6675
def email(name)
6776
body = IO.read EMAIL_FIXTURE_PATH.join("#{name}.txt").to_s
6877
EmailReplyParser.read body

test/emails/email_1_4.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Awesome! I haven't had another problem with it.
2+
3+
On Aug 22, 2011, at 7:37 PM, defunkt<reply@reply.github.com> wrote:
4+
5+
> Loader seems to be working well.

0 commit comments

Comments
 (0)