Sha256: 81221f8270df6b431031ee9a168e977e0063b0e9b5e3238df50e441ea04dcf22

Contents?: true

Size: 832 Bytes

Versions: 13

Compression:

Stored size: 832 Bytes

Contents

# encoding: utf-8
# frozen_string_literal: true
require 'mail/encodings/7bit'

module Mail
  module Encodings
    # Base64 encoding handles binary content at the cost of 4 output bytes
    # per input byte.
    class Base64 < SevenBit
      NAME = 'base64'
      PRIORITY = 3
      Encodings.register(NAME, self)

      def self.can_encode?(enc)
        true
      end

      def self.decode(str)
        Utilities.decode_base64(str)
      end

      def self.encode(str)
        ::Mail::Utilities.binary_unsafe_to_crlf(Utilities.encode_base64(str))
      end

      # 3 bytes in -> 4 bytes out
      def self.cost(str)
        4.0 / 3
      end

      # Ruby Base64 inserts newlines automatically, so it doesn't exceed
      # SMTP line length limits.
      def self.compatible_input?(str)
        true
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 4 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/mail-2.8.1/lib/mail/encodings/base64.rb
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/mail-2.8.1/lib/mail/encodings/base64.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/mail-2.8.1/lib/mail/encodings/base64.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/mail-2.8.1/lib/mail/encodings/base64.rb
tinymce-rails-7.1.2 vendor/bundle/ruby/3.3.0/gems/mail-2.8.1/lib/mail/encodings/base64.rb
mail-2.8.1 lib/mail/encodings/base64.rb
mail-2.8.1.rc2 lib/mail/encodings/base64.rb
mail-2.8.0.1 lib/mail/encodings/base64.rb
mail-2.8.0.1.rc1 lib/mail/encodings/base64.rb
mail-2.8.0 lib/mail/encodings/base64.rb
mail-2.8.0.rc3 lib/mail/encodings/base64.rb
mail-2.8.0.rc2 lib/mail/encodings/base64.rb
mail-2.8.0.rc1 lib/mail/encodings/base64.rb