Skip to content

Commit 9dcfe77

Browse files
authored
Merge pull request #81 from github/zkoppert-timeout
Add timeout to prevent infinite run
2 parents 6dbad76 + 30c803e commit 9dcfe77

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

lib/email_reply_parser.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ def scan_line(line)
147147
line.chomp!("\n")
148148
line.lstrip! unless SIG_REGEX.match(line)
149149

150-
# We're looking for leading `>`'s to see if this line is part of a
150+
# We're looking for a leading `>` to see if this line is part of a
151151
# quoted Fragment.
152-
is_quoted = !!(line =~ /(>+)$/)
152+
is_quoted = !!(line =~ /(>)$/)
153153

154154
# Mark the current Fragment as a signature if the current line is empty
155155
# and the Fragment starts with a common signature indicator.

test/email_reply_parser_test.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
require 'test/unit'
33
require 'pathname'
44
require 'pp'
5+
require 'timeout'
56

67
dir = Pathname.new File.expand_path(File.dirname(__FILE__))
78
require dir + '..' + 'lib' + 'email_reply_parser'
@@ -222,6 +223,12 @@ def test_doesnt_remove_signature_delimiter_in_mid_line
222223
assert_equal 1, reply.fragments.size
223224
end
224225

226+
def test_long_quote_processing_completes
227+
reply = Timeout.timeout(1) { email(:email_long_quote) }
228+
229+
assert_equal 5, reply.fragments.size
230+
end
231+
225232
def email(name)
226233
body = IO.read EMAIL_FIXTURE_PATH.join("#{name}.txt").to_s
227234
EmailReplyParser.read body

test/emails/email_long_quote.txt

Lines changed: 16 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)