aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionmailer/CHANGELOG2
-rw-r--r--actionmailer/lib/action_mailer/vendor/tmail/quoting.rb1
-rw-r--r--actionmailer/test/fixtures/raw_email_quoted_with_0d0a14
-rw-r--r--actionmailer/test/quoting_test.rb7
4 files changed, 24 insertions, 0 deletions
diff --git a/actionmailer/CHANGELOG b/actionmailer/CHANGELOG
index ba73da30a4..bac5eeafa5 100644
--- a/actionmailer/CHANGELOG
+++ b/actionmailer/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Make sure DOS newlines in quoted-printable text are normalized to unix newlines before unquoting. closes $166 and #4452. [Jamis Buck]
+
* Fixed that iconv decoding should catch InvalidEncoding #3153 [jon@siliconcircus.com]
* Tighten rescue clauses. #5985 [james@grayproductions.net]
diff --git a/actionmailer/lib/action_mailer/vendor/tmail/quoting.rb b/actionmailer/lib/action_mailer/vendor/tmail/quoting.rb
index c73157fe61..8fbb6e55de 100644
--- a/actionmailer/lib/action_mailer/vendor/tmail/quoting.rb
+++ b/actionmailer/lib/action_mailer/vendor/tmail/quoting.rb
@@ -68,6 +68,7 @@ module TMail
def unquote_quoted_printable_and_convert_to(text, to, from, preserve_underscores=false)
text = text.gsub(/_/, " ") unless preserve_underscores
+ text = text.gsub(/\r\n|\r/, "\n") # normalize newlines
convert_to(text.unpack("M*").first, to, from)
end
diff --git a/actionmailer/test/fixtures/raw_email_quoted_with_0d0a b/actionmailer/test/fixtures/raw_email_quoted_with_0d0a
new file mode 100644
index 0000000000..8a2c25a5dd
--- /dev/null
+++ b/actionmailer/test/fixtures/raw_email_quoted_with_0d0a
@@ -0,0 +1,14 @@
+Mime-Version: 1.0 (Apple Message framework v730)
+Message-Id: <9169D984-4E0B-45EF-82D4-8F5E53AD7012@example.com>
+From: foo@example.com
+Subject: testing
+Date: Mon, 6 Jun 2005 22:21:22 +0200
+To: blah@example.com
+Content-Transfer-Encoding: quoted-printable
+Content-Type: text/plain
+
+A fax has arrived from remote ID ''.=0D=0A-----------------------=
+-------------------------------------=0D=0ATime: 3/9/2006 3:50:52=
+ PM=0D=0AReceived from remote ID: =0D=0AInbound user ID XXXXXXXXXX, r=
+outing code XXXXXXXXX=0D=0AResult: (0/352;0/0) Successful Send=0D=0AP=
+age record: 1 - 1=0D=0AElapsed time: 00:58 on channel 11=0D=0A
diff --git a/actionmailer/test/quoting_test.rb b/actionmailer/test/quoting_test.rb
index 0b145b1f77..41d4ab680b 100644
--- a/actionmailer/test/quoting_test.rb
+++ b/actionmailer/test/quoting_test.rb
@@ -19,6 +19,13 @@ class QuotingTest < Test::Unit::TestCase
assert_equal unquoted, original
end
+ # test an email that has been created using \r\n newlines, instead of
+ # \n newlines.
+ def test_email_quoted_with_0d0a
+ mail = TMail::Mail.parse(IO.read("#{File.dirname(__FILE__)}/fixtures/raw_email_quoted_with_0d0a"))
+ assert_match %r{Elapsed time}, mail.body
+ end
+
private
# This whole thing *could* be much simpler, but I don't think Tempfile,