Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make sure DOS newlines in quoted-printable text are normalized to uni…

…x newlines before unquoting. closes $166 and #4452

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5079 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 3e7aa0391fb0da5ea6c38ceb682c8634d3a1cb72 1 parent 0a84624
@jamis jamis authored
View
2  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]
View
1  actionmailer/lib/action_mailer/vendor/tmail/quoting.rb
@@ -68,6 +68,7 @@ def unquote_and_convert_to(text, to_charset, from_charset = "iso-8859-1", preser
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
View
14 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
View
7 actionmailer/test/quoting_test.rb
@@ -19,6 +19,13 @@ def test_quote_multibyte_chars
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,
Please sign in to comment.
Something went wrong with that request. Please try again.