diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-03-21 12:21:43 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-03-21 12:21:43 +0000 |
commit | e995f81a2f40c550a24a9fb8264771087cc1fe46 (patch) | |
tree | 617a785514f47fea80d105b93a1ec448f57fcdb9 | |
parent | cb69736a1084d5412ede7628f864eccc356bb88c (diff) | |
download | rails-e995f81a2f40c550a24a9fb8264771087cc1fe46.tar.gz rails-e995f81a2f40c550a24a9fb8264771087cc1fe46.tar.bz2 rails-e995f81a2f40c550a24a9fb8264771087cc1fe46.zip |
Protect against nil strings and empty conversion bases
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@965 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r-- | actionmailer/lib/action_mailer/vendor/tmail/quoting.rb | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/actionmailer/lib/action_mailer/vendor/tmail/quoting.rb b/actionmailer/lib/action_mailer/vendor/tmail/quoting.rb index d5087f7610..c060863db5 100644 --- a/actionmailer/lib/action_mailer/vendor/tmail/quoting.rb +++ b/actionmailer/lib/action_mailer/vendor/tmail/quoting.rb @@ -4,11 +4,11 @@ require 'base64' module TMail class Mail def subject(to_charset = 'utf-8') - Unquoter.unquote_and_convert_to(quoted_subject || "", to_charset) + Unquoter.unquote_and_convert_to(quoted_subject, to_charset) end def unquoted_body(to_charset = 'utf-8') - Unquoter.unquote_and_convert_to(quoted_body || "", to_charset, header["content-type"]["charset"]) + Unquoter.unquote_and_convert_to(quoted_body, to_charset, header["content-type"]["charset"]) end def body(to_charset = 'utf-8', &block) @@ -29,6 +29,7 @@ module TMail class Unquoter class << self def unquote_and_convert_to(text, to_charset, from_charset = "iso-8859-1") + return "" if text.nil? if text =~ /^=\?(.*?)\?(.)\?(.*)\?=$/ from_charset = $1 quoting_method = $2 @@ -47,11 +48,11 @@ module TMail end def unquote_quoted_printable_and_convert_to(text, from, to) - Iconv.iconv(to, from, text.gsub(/_/," ").unpack("M*").first).first + text ? Iconv.iconv(to, from || "ISO-8859-1", text.gsub(/_/," ").unpack("M*").first).first : "" end def unquote_base64_and_convert_to(text, from, to) - Iconv.iconv(to, from, Base64.decode64(text)).first + text ? Iconv.iconv(to, from || "ISO-8859-1", Base64.decode64(text)).first : "" end end end |