diff options
author | Louise Crow <louise.crow@gmail.com> | 2013-08-20 09:51:18 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2013-08-20 09:51:18 +0100 |
commit | 3d12cbe6ee7ff49dad9a473efc0792b2a4f4cba6 (patch) | |
tree | 1c43d3a004293f442f61b0e64847a4ef16cacd2a /lib/mail_handler/backends | |
parent | c449240a1b1cddebb53e9748b15be43c0f65c463 (diff) | |
parent | 4b95ccffc468c256d6ba6248303dd2b78bf5896a (diff) |
Merge branch 'release/0.13' into wdtk
Conflicts:
locale/he_IL/app.po
locale/hr_HR/app.po
locale/nb_NO/app.po
locale/uk/app.po
Diffstat (limited to 'lib/mail_handler/backends')
-rw-r--r-- | lib/mail_handler/backends/mail_extensions.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/mail_handler/backends/mail_extensions.rb b/lib/mail_handler/backends/mail_extensions.rb index 6d6a20f8c..029331802 100644 --- a/lib/mail_handler/backends/mail_extensions.rb +++ b/lib/mail_handler/backends/mail_extensions.rb @@ -46,6 +46,15 @@ module Mail self end + + def set_envelope_header + raw_string = raw_source.to_s + if match_data = raw_source.to_s.match(/\AFrom\s(#{TEXT}+)#{CRLF}/m) + set_envelope(match_data[1]) + self.raw_source = raw_string.sub(match_data[0], "") + end + end + end # A patched version of the parameter hash that handles nil values without throwing @@ -117,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 |