Sha256: 63aa0740997e24102555fbab0f51002810a8efa6c1fb4af3c74bd4c5a2f6d3c5

Contents?: true

Size: 741 Bytes

Versions: 4

Compression:

Stored size: 741 Bytes

Contents

module Mail
  module Jdec
    module ContentDispositionElementPatch
      def initialize(string)
        super
      rescue Mail::Field::ParseError => e
        if Jdec.enabled?
          value = Jdec::Decoder.force_utf8(string)
          if (matched = value.match(/^\s*attachment\s*;\s*(.+)/im))
            @disposition_type = 'attachment'
            @parameters = [{ filename: matched[1].gsub(/(\r\n|\r|\n)\s/, '') }]
          else
            raise e
          end
        else
          raise e
        end
      end
    end
  end
end

unless Mail::ContentDispositionElement.included_modules.include?(Mail::Jdec::ContentDispositionElementPatch)
  Mail::ContentDispositionElement.prepend Mail::Jdec::ContentDispositionElementPatch
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mail-jdec-1.0.3 lib/mail/jdec/elements/content_disposition_element_patch.rb
mail-jdec-1.0.2 lib/mail/jdec/elements/content_disposition_element_patch.rb
mail-jdec-1.0.1 lib/mail/jdec/elements/content_disposition_element_patch.rb
mail-jdec-1.0.0 lib/mail/jdec/elements/content_disposition_element_patch.rb