Sha256: 67b19657096ccf63ef9e72fce0ac0d57197765c6d02d97444395f180459d0341

Contents?: true

Size: 981 Bytes

Versions: 22

Compression:

Stored size: 981 Bytes

Contents

# frozen_string_literal: true
module Mail::Parsers
  class ContentTransferEncodingParser

    def parse(s)
      content_transfer_encoding = ContentTransferEncodingStruct.new("")
      if Mail::Utilities.blank?(s)
        return content_transfer_encoding
      end

      actions, error = Ragel.parse(:content_transfer_encoding, s)
      if error
        raise Mail::Field::ParseError.new(Mail::ContentTransferEncodingElement, s, error)
      end

      encoding_s = nil
      actions.each_slice(2) do |action_id, p|
        action = Mail::Parsers::Ragel::ACTIONS[action_id]
        case action

        # Encoding
        when :encoding_s then encoding_s = p
        when :encoding_e
          content_transfer_encoding.encoding = s[encoding_s..(p-1)].downcase

        else
          raise Mail::Field::ParseError.new(Mail::ContentTransferEncodingElement, s, "Failed to process unknown action: #{action}")
        end
      end

      content_transfer_encoding
    end
  end
end

Version data entries

22 entries across 20 versions & 6 rubygems

Version Path
tdiary-5.0.6 vendor/bundle/gems/mail-2.6.6/lib/mail/parsers/content_transfer_encoding_parser.rb
tdiary-5.0.5 vendor/bundle/gems/mail-2.6.4/lib/mail/parsers/content_transfer_encoding_parser.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/mail-2.6.4/lib/mail/parsers/content_transfer_encoding_parser.rb
tdiary-5.0.5 vendor/bundle/gems/mail-2.6.6/lib/mail/parsers/content_transfer_encoding_parser.rb
mail-2.6.6 lib/mail/parsers/content_transfer_encoding_parser.rb
mail-2.6.6.rc1 lib/mail/parsers/content_transfer_encoding_parser.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/mail-2.6.5/lib/mail/parsers/content_transfer_encoding_parser.rb
mail-2.6.5 lib/mail/parsers/content_transfer_encoding_parser.rb
mail-2.6.5.rc1 lib/mail/parsers/content_transfer_encoding_parser.rb
tdiary-5.0.4 vendor/bundle/gems/mail-2.6.4/lib/mail/parsers/content_transfer_encoding_parser.rb
autocompl-0.2.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/mail-2.6.4/lib/mail/parsers/content_transfer_encoding_parser.rb
autocompl-0.2.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/mail-2.6.4/lib/mail/parsers/content_transfer_encoding_parser.rb
autocompl-0.2.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/mail-2.6.4/lib/mail/parsers/content_transfer_encoding_parser.rb
autocompl-0.1.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/mail-2.6.4/lib/mail/parsers/content_transfer_encoding_parser.rb
autocompl-0.1.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/mail-2.6.4/lib/mail/parsers/content_transfer_encoding_parser.rb
autocompl-0.1.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/mail-2.6.4/lib/mail/parsers/content_transfer_encoding_parser.rb
autocompl-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/mail-2.6.4/lib/mail/parsers/content_transfer_encoding_parser.rb
abaci-0.3.0 vendor/bundle/gems/mail-2.6.4/lib/mail/parsers/content_transfer_encoding_parser.rb
tdiary-5.0.2 vendor/bundle/gems/mail-2.6.4/lib/mail/parsers/content_transfer_encoding_parser.rb
tdiary-5.0.1 vendor/bundle/gems/mail-2.6.4/lib/mail/parsers/content_transfer_encoding_parser.rb