Sha256: 33a08fda5f8be8e7ceb34b7e6e53b9f95739bbb6ebf8a277c9a0f907fff84698

Contents?: true

Size: 1.04 KB

Versions: 22

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true
module Mail::Parsers
  class ContentLocationParser
    def parse(s)
      content_location = ContentLocationStruct.new(nil)
      if Mail::Utilities.blank?(s)
        return content_location
      end

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

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

        # Quoted String.
        when :qstr_s then qstr_s = p
        when :qstr_e then content_location.location = s[qstr_s..(p-1)]

        # Token String
        when :token_string_s then token_string_s = p
        when :token_string_e
          content_location.location = s[token_string_s..(p-1)]

        else
          raise Mail::Field::ParseError.new(Mail::ContentLocationElement, s, "Failed to process unknown action: #{action}")
        end
      end
      content_location
    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_location_parser.rb
tdiary-5.0.5 vendor/bundle/gems/mail-2.6.4/lib/mail/parsers/content_location_parser.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/mail-2.6.4/lib/mail/parsers/content_location_parser.rb
tdiary-5.0.5 vendor/bundle/gems/mail-2.6.6/lib/mail/parsers/content_location_parser.rb
mail-2.6.6 lib/mail/parsers/content_location_parser.rb
mail-2.6.6.rc1 lib/mail/parsers/content_location_parser.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/mail-2.6.5/lib/mail/parsers/content_location_parser.rb
mail-2.6.5 lib/mail/parsers/content_location_parser.rb
mail-2.6.5.rc1 lib/mail/parsers/content_location_parser.rb
tdiary-5.0.4 vendor/bundle/gems/mail-2.6.4/lib/mail/parsers/content_location_parser.rb
autocompl-0.2.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/mail-2.6.4/lib/mail/parsers/content_location_parser.rb
autocompl-0.2.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/mail-2.6.4/lib/mail/parsers/content_location_parser.rb
autocompl-0.2.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/mail-2.6.4/lib/mail/parsers/content_location_parser.rb
autocompl-0.1.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/mail-2.6.4/lib/mail/parsers/content_location_parser.rb
autocompl-0.1.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/mail-2.6.4/lib/mail/parsers/content_location_parser.rb
autocompl-0.1.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/mail-2.6.4/lib/mail/parsers/content_location_parser.rb
autocompl-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/mail-2.6.4/lib/mail/parsers/content_location_parser.rb
abaci-0.3.0 vendor/bundle/gems/mail-2.6.4/lib/mail/parsers/content_location_parser.rb
tdiary-5.0.2 vendor/bundle/gems/mail-2.6.4/lib/mail/parsers/content_location_parser.rb
tdiary-5.0.1 vendor/bundle/gems/mail-2.6.4/lib/mail/parsers/content_location_parser.rb