diff options
author | Mark Longair <mhl@pobox.com> | 2013-11-26 15:23:05 +0000 |
---|---|---|
committer | Mark Longair <mhl@pobox.com> | 2013-11-29 08:59:35 +0000 |
commit | c64692cd3d10f7432c9d5350610a6799b1e1419b (patch) | |
tree | 6c88ec5067d3fbbf16b3050184e4db8e931445da /lib/mail_handler/backends | |
parent | f91d66d42f517f778cac130466b7cffc7fd8b085 (diff) | |
parent | 70ae965de187244d5fde7dfff9c1c274fbba581f (diff) |
Merge branch 'feature/rails-3-2-upgrade-spike' into feature/switch-to-asset-pipeline
Conflicts:
Gemfile.lock
app/assets/images/admin-theme/ui-bg_flat_0_aaaaaa_40x100.png
app/assets/images/admin-theme/ui-bg_flat_55_fbf9ee_40x100.png
app/assets/images/admin-theme/ui-bg_flat_65_ffffff_40x100.png
app/assets/images/admin-theme/ui-bg_flat_75_cccccc_40x100.png
app/assets/images/admin-theme/ui-bg_flat_75_dadada_40x100.png
app/assets/images/admin-theme/ui-bg_flat_75_e6e6e6_40x100.png
app/assets/images/admin-theme/ui-bg_flat_75_ffffff_40x100.png
app/assets/images/admin-theme/ui-bg_inset-soft_95_fef1ec_1x100.png
app/assets/images/admin-theme/ui-icons_222222_256x240.png
app/assets/images/admin-theme/ui-icons_2e83ff_256x240.png
app/assets/images/admin-theme/ui-icons_454545_256x240.png
app/assets/images/admin-theme/ui-icons_888888_256x240.png
app/assets/images/admin-theme/ui-icons_cd0a0a_256x240.png
app/assets/javascripts/admin.js
app/assets/javascripts/admin/jquery-ui.min.js
app/assets/javascripts/application.js
app/assets/javascripts/jquery-ui.min.js
app/assets/javascripts/jquery.flot.errorbars.min.js
app/assets/javascripts/jquery.flot.min.js
app/assets/javascripts/stats.js
app/assets/stylesheets/application.css
app/assets/stylesheets/fonts.scss
app/views/general/_stylesheet_includes.html.erb
app/views/layouts/admin.html.erb
app/views/layouts/default.html.erb
app/views/public_body/statistics.html.erb
config/application.rb
config/environments/development.rb
Diffstat (limited to 'lib/mail_handler/backends')
-rw-r--r-- | lib/mail_handler/backends/mail_backend.rb | 4 | ||||
-rw-r--r-- | lib/mail_handler/backends/mail_extensions.rb | 66 |
2 files changed, 5 insertions, 65 deletions
diff --git a/lib/mail_handler/backends/mail_backend.rb b/lib/mail_handler/backends/mail_backend.rb index 28c486e1b..e019eba97 100644 --- a/lib/mail_handler/backends/mail_backend.rb +++ b/lib/mail_handler/backends/mail_backend.rb @@ -95,7 +95,7 @@ module MailHandler def get_from_address(mail) first_from = first_from(mail) if first_from - if first_from.is_a?(ActiveSupport::Multibyte::Chars) + if first_from.is_a?(String) return nil else return first_from.address @@ -109,7 +109,7 @@ module MailHandler def get_from_name(mail) first_from = first_from(mail) if first_from - if first_from.is_a?(ActiveSupport::Multibyte::Chars) + if first_from.is_a?(String) return nil else return (first_from.display_name || nil) diff --git a/lib/mail_handler/backends/mail_extensions.rb b/lib/mail_handler/backends/mail_extensions.rb index 029331802..87af526bf 100644 --- a/lib/mail_handler/backends/mail_extensions.rb +++ b/lib/mail_handler/backends/mail_extensions.rb @@ -7,54 +7,6 @@ module Mail attr_accessor :within_rfc822_attachment # for parts within a message attached as text (for getting subject mainly) attr_accessor :count_parts_count attr_accessor :count_first_uudecode_count - - # A patched version of the message initializer to work around a bug where stripping the original - # input removes meaningful spaces - e.g. in the case of uuencoded bodies. - def initialize(*args, &block) - @body = nil - @body_raw = nil - @separate_parts = false - @text_part = nil - @html_part = nil - @errors = nil - @header = nil - @charset = 'UTF-8' - @defaulted_charset = true - - @perform_deliveries = true - @raise_delivery_errors = true - - @delivery_handler = nil - - @delivery_method = Mail.delivery_method.dup - - @transport_encoding = Mail::Encodings.get_encoding('7bit') - - @mark_for_delete = false - - if args.flatten.first.respond_to?(:each_pair) - init_with_hash(args.flatten.first) - else - # The replacement of this commented out line is the change. - # init_with_string(args.flatten[0].to_s.strip) - init_with_string(args.flatten[0].to_s) - end - - if block_given? - instance_eval(&block) - end - - 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 @@ -77,6 +29,7 @@ module Mail # HACK: Backport encoding fixes for Ruby 1.8 from Mail 2.5 # Can be removed when we no longer support Ruby 1.8 class Ruby18 + def Ruby18.b_value_decode(str) match = str.match(/\=\?(.+)?\?[Bb]\?(.+)?\?\=/m) if match @@ -129,11 +82,11 @@ module Mail def Ruby19.b_value_decode(str) match = str.match(/\=\?(.+)?\?[Bb]\?(.+)?\?\=/m) if match - encoding = match[1] + charset = match[1] str = Ruby19.decode_base64(match[2]) # Rescue an ArgumentError arising from an unknown encoding. begin - str.force_encoding(fix_encoding(encoding)) + str.force_encoding(pick_encoding(charset)) rescue ArgumentError end end @@ -141,18 +94,5 @@ module Mail 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 - encoding = match[1] - str = Encodings::QuotedPrintable.decode(match[2].gsub(/_/, '=20')) - # Backport line from mail 2.5 to strip a trailing = character - # Remove trailing = if it exists in a Q encoding - str = str.sub(/\=$/, '') - str.force_encoding(fix_encoding(encoding)) - end - decoded = str.encode("utf-8", :invalid => :replace, :replace => "") - decoded.valid_encoding? ? decoded : decoded.encode("utf-16le", :invalid => :replace, :replace => "").encode("utf-8") - end end end |