mirror of https://github.com/rails/rails
Silently ignore Errno::EINVAL errors when converting between charsets. Some mail clients apprently send X-UNKNOWN to represent unknown charsets, and this caused the conversion to blow up.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1395 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
b0a35b6fe9
commit
29d6d15fc3
|
@ -1,5 +1,7 @@
|
|||
*SVN*
|
||||
|
||||
* Silently ignore Errno::EINVAL errors when converting text.
|
||||
|
||||
* Don't cause an error when parsing an encoded attachment name #1340 [lon@speedymac.com]
|
||||
|
||||
* Nested multipart message parts are correctly processed in TMail::Mail#body
|
||||
|
|
|
@ -79,10 +79,13 @@ module TMail
|
|||
def convert_to(text, to, from)
|
||||
return text unless to && from
|
||||
text ? Iconv.iconv(to, from, text).first : ""
|
||||
rescue Iconv::IllegalSequence
|
||||
rescue Iconv::IllegalSequence, Errno::EINVAL
|
||||
# the 'from' parameter specifies a charset other than what the text
|
||||
# actually is...not much we can do in this case but just return the
|
||||
# unconverted text.
|
||||
#
|
||||
# Ditto if either parameter represents an unknown charset, like
|
||||
# X-UNKNOWN.
|
||||
text
|
||||
end
|
||||
rescue LoadError
|
||||
|
|
|
@ -515,5 +515,11 @@ EOF
|
|||
fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email9")
|
||||
assert_raise(TMail::SyntaxError) { TMail::Mail.parse(fixture) }
|
||||
end
|
||||
|
||||
def test_decode_message_with_unknown_charset
|
||||
fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email10")
|
||||
mail = TMail::Mail.parse(fixture)
|
||||
assert_nothing_raised { mail.body }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue