Class: Yast::URLRecodeClass

Inherits:
Module
  • Object
show all
Defined in:
library/types/src/modules/URLRecode.rb

Overview

A drop-in replacement of an earlier Perl implementation

Constant Summary collapse

USERNAME_PASSWORD_FRAGMENT_SAFE_CHARS =

these will be substituted to a regex character class

"-A-Za-z0-9_.!~*'()".freeze
PATH_SAFE_CHARS =
"-A-Za-z0-9_.!~*'()/:".freeze
QUERY_SAFE_CHARS =
"-A-Za-z0-9_.!~*'()/:=&".freeze

Instance Method Summary collapse

Instance Method Details

#EscapePassword(input) ⇒ String

Escape password, user name and fragment part of URL string

Parameters:

  • input (String)

    input string

Returns:


16
17
18
# File 'library/types/src/modules/URLRecode.rb', line 16

def EscapePassword(input)
  escape(input, USERNAME_PASSWORD_FRAGMENT_SAFE_CHARS)
end

#EscapePath(input) ⇒ String

Escape path part of URL string

Parameters:

  • input (String)

    input string

Returns:


23
24
25
# File 'library/types/src/modules/URLRecode.rb', line 23

def EscapePath(input)
  escape(input, PATH_SAFE_CHARS)
end

#EscapeQuery(input) ⇒ String

Escape path part of URL string

Parameters:

  • input (String)

    input string

Returns:


30
31
32
# File 'library/types/src/modules/URLRecode.rb', line 30

def EscapeQuery(input)
  escape(input, QUERY_SAFE_CHARS)
end

#UnEscape(input) ⇒ String

UnEscape an URL string, replace % sequences by character

Parameters:

  • input (String)

    input string

Returns:

  • (String)

    Unescaped string


38
39
40
# File 'library/types/src/modules/URLRecode.rb', line 38

def UnEscape(input)
  input.gsub(/%([0-9A-Fa-f]{2})/) { Regexp.last_match[1].to_i(16).chr }.force_encoding(input.encoding)
end