提交 3e7aa039 编写于 作者: J Jamis Buck

Make sure DOS newlines in quoted-printable text are normalized to unix...

Make sure DOS newlines in quoted-printable text are normalized to unix newlines before unquoting. closes $166 and #4452


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5079 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 0a84624b
*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]
......
......@@ -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
......
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
......@@ -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,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册