aboutsummaryrefslogtreecommitdiffstats
path: root/lib/mail_handler/backends
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2013-08-20 15:58:11 +0100
committerLouise Crow <louise.crow@gmail.com>2013-08-20 15:58:11 +0100
commitce30500cea5c2d6304643bc90ce0c5b36a2f5919 (patch)
tree92ef48879721d017e7b72e663ef8dbc3d6421fb0 /lib/mail_handler/backends
parentf757ce4ba02c6621e04a349376aeda1c1cb553a3 (diff)
parentdfb5f97ac44656f0e021b09856e0c54b9fa41b3f (diff)
Merge branch 'release/0.13'0.13
Conflicts: locale/bg/app.po locale/es/app.po locale/fi/app.po locale/fr/app.po locale/fr_CA/app.po locale/he_IL/app.po locale/hr/app.po locale/nb_NO/app.po locale/nl/app.po locale/pt_BR/app.po locale/ro_RO/app.po locale/sl/app.po locale/vi/app.po script/rails-post-deploy
Diffstat (limited to 'lib/mail_handler/backends')
-rw-r--r--lib/mail_handler/backends/mail_extensions.rb20
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/mail_handler/backends/mail_extensions.rb b/lib/mail_handler/backends/mail_extensions.rb
index 87d8710f7..029331802 100644
--- a/lib/mail_handler/backends/mail_extensions.rb
+++ b/lib/mail_handler/backends/mail_extensions.rb
@@ -87,7 +87,10 @@ module Mail
# invalid character at the end of the string, even
# with UTF-8//IGNORE:
# http://po-ru.com/diary/fixing-invalid-utf-8-in-ruby-revisited/
- str = Iconv.conv('UTF-8//IGNORE', fix_encoding(encoding), str + " ")[0...-4]
+ begin
+ str = Iconv.conv('UTF-8//IGNORE', fix_encoding(encoding), str + " ")[0...-4]
+ rescue Iconv::InvalidEncoding
+ end
end
str
end
@@ -123,6 +126,21 @@ module Mail
end
class Ruby19
+ def Ruby19.b_value_decode(str)
+ match = str.match(/\=\?(.+)?\?[Bb]\?(.+)?\?\=/m)
+ if match
+ encoding = match[1]
+ str = Ruby19.decode_base64(match[2])
+ # Rescue an ArgumentError arising from an unknown encoding.
+ begin
+ str.force_encoding(fix_encoding(encoding))
+ rescue ArgumentError
+ end
+ end
+ decoded = str.encode("utf-8", :invalid => :replace, :replace => "")
+ decoded.valid_encoding? ? decoded : decoded.encode("utf-16le", :invalid => :replace, :replace => "").encode("utf-8")
+ end
+
def Ruby19.q_value_decode(str)
match = str.match(/\=\?(.+)?\?[Qq]\?(.+)?\?\=/m)
if match