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

See Also:

Since:

  • 1.0.0

API:

  • public

Class Method Summary collapse

Class Method Details

.decode(data) ⇒ String

Alias for unescape.

See Also:

Since:

  • 1.0.0

Parameters:

  • The Quoted-Printable String to unescape.

Returns:

  • The unescaped String.

API:

  • public



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.

See Also:

Since:

  • 1.0.0

Parameters:

  • The data to escape.

Returns:

  • The quoted-printable escaped String.

API:

  • public



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"

See Also:

Since:

  • 1.0.0

Parameters:

  • The data to escape.

Returns:

  • The quoted-printable escaped String.

API:

  • public



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>"

See Also:

Since:

  • 1.0.0

Parameters:

  • The Quoted-Printable String to unescape.

Returns:

  • The unescaped String.

API:

  • public



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

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