Class: Mail::Ruby18

### Home Classes Methods

### In Files

- lib/mail/version_specific/ruby_1_8.rb

### Parent

Object

### Methods

- ::b_value_decode
- ::b_value_encode
- ::bracket
- ::decode_base64
- ::encode_base64
- ::escape_bracket
- ::escape_paren
- ::get_constant
- ::has_constant?
- ::param_decode
- ::param_encode
- ::paren
- ::q_value_decode
- ::q_value_encode

### Files

- TODO.rdoc

### Class/Module Index

Quicksearch

- Mail
- Mail::Address
- Mail::AddressContainer
- Mail::AttachmentsList
- Mail::BccField
- Mail::Body
- Mail::CcField
- Mail::CheckDeliveryParams
- Mail::CommentsField
- Mail::Constants
- Mail::ContentDescriptionField
- Mail::ContentDispositionField
- Mail::ContentIdField
- Mail::ContentLocationField
- Mail::ContentTransferEncodingElement
- Mail::ContentTransferEncodingField
- Mail::ContentTypeField
- Mail::DateField
- Mail::Encodings
- Mail::Encodings::Base64
- Mail::Encodings::Binary
- Mail::Encodings::EightBit
- Mail::Encodings::QuotedPrintable
- Mail::Encodings::SevenBit
- Mail::Encodings::TransferEncoding
- Mail::Encodings::UnixToUnix
- Mail::Envelope
- Mail::EnvelopeFromElement
- Mail::Exim
- Mail::Field
- Mail::Field::FieldError
- Mail::FieldList
- Mail::FileDelivery
- Mail::FromField
- Mail::Header
- Mail::IMAP
- Mail::InReplyToField
- Mail::IndifferentHash
- Mail::KeywordsField
- Mail::Matchers
- Mail::Matchers::HasSentEmailMatcher
- Mail::MessageIdField
- Mail::MessageIdsElement
- Mail::MimeVersionElement
- Mail::MimeVersionField
- Mail::Multibyte
- Mail::Multibyte::EncodingError
- Mail::OptionalField
- Mail::POP3
- Mail::ParameterHash
- Mail::Parsers
- Mail::Parsers::AddressListsParser
- Mail::Parsers::ContentDispositionParser
- Mail::Parsers::ContentLocationParser
- Mail::Parsers::ContentTransferEncodingParser
- Mail::Parsers::ContentTypeParser
- Mail::Parsers::DateTimeParser
- Mail::Parsers::EnvelopeFromParser
- Mail::Parsers::MessageIdsParser
- Mail::Parsers::MimeVersionParser
- Mail::Parsers::PhraseListsParser
- Mail::Parsers::Ragel
- Mail::Parsers::Ragel::AddressListsMachine
- Mail::Parsers::Ragel::ContentDispositionMachine
- Mail::Parsers::Ragel::ContentLocationMachine
- Mail::Parsers::Ragel::ContentTransferEncodingMachine
- Mail::Parsers::Ragel::ContentTypeMachine
- Mail::Parsers::Ragel::DateTimeMachine
- Mail::Parsers::Ragel::EnvelopeFromMachine
- Mail::Parsers::Ragel::MessageIdsMachine
- Mail::Parsers::Ragel::MimeVersionMachine
- Mail::Parsers::Ragel::PhraseListsMachine
- Mail::Parsers::Ragel::ReceivedMachine
- Mail::Parsers::Ragel::Ruby
- Mail::Parsers::ReceivedParser
- Mail::Part
- Mail::PartsList
- Mail::PhraseList
- Mail::ReceivedElement
- Mail::ReceivedField
- Mail::ReferencesField
- Mail::ReplyToField
- Mail::ResentBccField
- Mail::ResentCcField
- Mail::ResentDateField
- Mail::ResentFromField
- Mail::ResentMessageIdField
- Mail::ResentSenderField
- Mail::ResentToField
- Mail::Retriever
- Mail::ReturnPathField
- Mail::Ruby18
- Mail::Ruby19
- Mail::Ruby19::BestEffortCharsetEncoder
- Mail::Ruby19::StrictCharsetEncoder
- Mail::SMTP
- Mail::SMTPConnection
- Mail::SenderField
- Mail::Sendmail
- Mail::StructuredField
- Mail::SubjectField
- Mail::TestMailer
- Mail::TestRetriever
- Mail::ToField
- Mail::UnstructuredField
- Mail::Utilities
- Mail::VERSION
- Net
- Net::SMTP
- Object
- String

No matching classes.

# Mail::Ruby18

### Public Class Methods

b_value_decode(str) click to toggle source

    # File lib/mail/version_specific/ruby_1_8.rb, line 63
    def Ruby18.b_value_decode(str)
      match = str.match(/\=\?(.+)?\?[Bb]\?(.*)\?\=/)
      if match
        encoding = match[1]
        str = Ruby18.decode_base64(match[2])
        str = Iconv.conv('UTF-8//IGNORE', fix_encoding(encoding), str)
      end
      str
    end

b_value_encode(str, encoding) click to toggle source

    # File lib/mail/version_specific/ruby_1_8.rb, line 56
    def Ruby18.b_value_encode(str, encoding)
      # Ruby 1.8 requires an encoding to work
      raise ArgumentError, "Must supply an encoding" if encoding.nil?
      encoding = encoding.to_s.upcase.gsub('_', '-')
      [Encodings::Base64.encode(str), fix_encoding(encoding)]
    end

bracket( str ) click to toggle source

    # File lib/mail/version_specific/ruby_1_8.rb, line 34
    def Ruby18.bracket( str )
      str = $1 if str =~ /^\<(.*)?\>$/
      str = escape_bracket( str )
      '<' + str + '>'
    end

decode_base64(str) click to toggle source

    # File lib/mail/version_specific/ruby_1_8.rb, line 40
    def Ruby18.decode_base64(str)
      Base64.decode64(str) if str
    end

encode_base64(str) click to toggle source

    # File lib/mail/version_specific/ruby_1_8.rb, line 44
    def Ruby18.encode_base64(str)
      Base64.encode64(str)
    end

escape_bracket( str ) click to toggle source

    # File lib/mail/version_specific/ruby_1_8.rb, line 25
    def Ruby18.escape_bracket( str )
      re = /\\\>/
      str = str.gsub(re) { |s| '>'}
      re = /\\\</
      str = str.gsub(re) { |s| '<'}
      re = /([\<\>])/          # Only match unescaped parens
      str.gsub(re) { |s| '\' + s }
    end

escape_paren( str ) click to toggle source

Escapes any parenthesis in a string that are unescaped. This can't use the Ruby 1.9.1 regexp feature of negative look behind so we have to do two replacement, first unescape everything, then re-escape it

    # File lib/mail/version_specific/ruby_1_8.rb, line 10
    def Ruby18.escape_paren( str )
      re = /\\\)/
      str = str.gsub(re) { |s| ')'}
      re = /\\\(/
      str = str.gsub(re) { |s| '('}
      re = /([\(\)])/          # Only match unescaped parens
      str.gsub(re) { |s| '\' + s }
    end

get_constant(klass, string) click to toggle source

    # File lib/mail/version_specific/ruby_1_8.rb, line 52
    def Ruby18.get_constant(klass, string)
      klass.const_get( string )
    end

has_constant?(klass, string) click to toggle source

    # File lib/mail/version_specific/ruby_1_8.rb, line 48
    def Ruby18.has_constant?(klass, string)
      klass.constants.include?( string )
    end

param_decode(str, encoding) click to toggle source

    # File lib/mail/version_specific/ruby_1_8.rb, line 93
    def Ruby18.param_decode(str, encoding)
      URI.unescape(str)
    end

param_encode(str) click to toggle source

    # File lib/mail/version_specific/ruby_1_8.rb, line 97
    def Ruby18.param_encode(str)
      encoding = $KCODE.to_s.downcase
      language = Configuration.instance.param_encode_language
      "#{encoding}'#{language}'#{URI.escape(str)}"
    end

paren( str ) click to toggle source

    # File lib/mail/version_specific/ruby_1_8.rb, line 19
    def Ruby18.paren( str )
      str = $1 if str =~ /^\((.*)?\)$/
      str = escape_paren( str )
      '(' + str + ')'
    end

q_value_decode(str) click to toggle source

    # File lib/mail/version_specific/ruby_1_8.rb, line 80
    def Ruby18.q_value_decode(str)
      match = str.match(/\=\?(.+)?\?[Qq]\?(.*)\?\=/)
      if match
        encoding = match[1]
        string = match[2].gsub(/_/, '=20')
        # Remove trailing = if it exists in a Q encoding
        string = string.sub(/\=$/, '')
        str = Encodings::QuotedPrintable.decode(string)
        str = Iconv.conv('UTF-8//IGNORE', fix_encoding(encoding), str)
      end
      str
    end

q_value_encode(str, encoding) click to toggle source

    # File lib/mail/version_specific/ruby_1_8.rb, line 73
    def Ruby18.q_value_encode(str, encoding)
      # Ruby 1.8 requires an encoding to work
      raise ArgumentError, "Must supply an encoding" if encoding.nil?
      encoding = encoding.to_s.upcase.gsub('_', '-')
      [Encodings::QuotedPrintable.encode(str), encoding]
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.