Permalink
Browse files

Condense multiline reply headers to a single line.

  • Loading branch information...
1 parent 074ea4f commit a1b29a6227f66ebb5bd4bb3366ef20dc8d3b6d12 @defunkt committed Dec 16, 2011
Showing with 30 additions and 0 deletions.
  1. +7 −0 lib/email_reply_parser.rb
  2. +8 −0 test/email_reply_parser_test.rb
  3. +15 −0 test/emails/email_1_5.txt
@@ -60,6 +60,13 @@ def initialize
#
# Returns this same Email instance.
def read(text)
+ # Check for multi-line reply headers. Some clients break up
+ # the "On DATE, NAME <EMAIL> wrote:" line into multiple lines.
+ if text =~ /^(On(.+)wrote:)$/m
+ # Remove all new lines from the reply header.
+ text.gsub! $1, $1.gsub("\n", " ")
+ end
+
# The text is reversed initially due to the way we check for hidden
# fragments.
text = text.reverse
@@ -71,6 +71,14 @@ def test_recognizes_date_string_above_quote
assert_match /Loader/, reply.fragments[1].to_s
end
+ def test_deals_with_multiline_reply_headers
+ reply = email :email_1_5
+
+ assert_match /^I get/, reply.fragments[0].to_s
+ assert_match /^On/, reply.fragments[1].to_s
+ assert_match /Was this/, reply.fragments[1].to_s
+ end
+
def test_does_not_modify_input_string
original = "The Quick Brown Fox Jumps Over The Lazy Dog"
EmailReplyParser.read original
View
@@ -0,0 +1,15 @@
+I get proper rendering as well.
+
+Sent from a magnificent torch of pixels
+
+On Dec 16, 2011, at 12:47 PM, Corey Donohoe
+<reply@reply.github.com>
+wrote:
+
+> Was this caching related or fixed already? I get proper rendering here.
+>
+> ![](https://img.skitch.com/20111216-m9munqjsy112yqap5cjee5wr6c.jpg)
+>
+> ---
+> Reply to this email directly or view it on GitHub:
+> https://github.com/github/github/issues/2278#issuecomment-3182418

2 comments on commit a1b29a6

dapi replied Jan 30, 2012

email_1_5.txt - what is email client name?

Owner

defunkt replied Jan 31, 2012

@dapi Mail on iPhone

Please sign in to comment.