Module: Ronin::Support::Encoding::QuotedPrintable

Defined in:
lib/ronin/support/encoding/quoted_printable.rb

Overview

Contains methods for encoding/decoding [Quoted Printable] data.

Core-Ext Methods

Since:

  • 1.0.0

Class Method Summary collapse

Class Method Details

.decode(data) ⇒ String

Alias for unescape.

Parameters:

  • data (String)

    The Quoted-Printable String to unescape.

Returns:

  • (String)

    The unescaped String.

See Also:

Since:

  • 1.0.0



101
102
103
# File 'lib/ronin/support/encoding/quoted_printable.rb', line 101

def self.decode(data)
  unescape(data)
end

.encode(data) ⇒ String

Alias for escape.

Parameters:

  • data (String)

    The data to escape.

Returns:

  • (String)

    The quoted-printable escaped String.

See Also:

Since:

  • 1.0.0



67
68
69
# File 'lib/ronin/support/encoding/quoted_printable.rb', line 67

def self.encode(data)
  escape(data)
end

.escape(data) ⇒ String

Escapes the data as Quoted-Printable.

Examples:

Encoding::QuotedPrintable.escape('<a href="https://example.com/">link</a>')
# => "<a href=3D\"https://example.com/\">link</a>=\n"

Parameters:

  • data (String)

    The data to escape.

Returns:

  • (String)

    The quoted-printable escaped String.

Since:

  • 1.0.0



52
53
54
# File 'lib/ronin/support/encoding/quoted_printable.rb', line 52

def self.escape(data)
  [data].pack('M')
end

.unescape(data) ⇒ String

Unescapes a Quoted-Printable encoded String.

Examples:

Encoding::QuotedPrintable.unescape("<a href=3D\"https://example.com/\">link</a>=\n")
# => "<a href=\"https://example.com/\">link</a>"

Parameters:

  • data (String)

    The Quoted-Printable String to unescape.

Returns:

  • (String)

    The unescaped String.

Since:

  • 1.0.0



86
87
88
# File 'lib/ronin/support/encoding/quoted_printable.rb', line 86

def self.unescape(data)
  data.unpack1('M')
end