Class: Yast::URLRecodeClass

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

Overview

Note:

This is legacy code ported from the

A drop-in replacement of an earlier Perl implementation

YCP era. Its use is highly discouraged in favor of the URI standard library or the new Y2Packager::ZyppUrl (available from SLE-15-SP3 on) when working with libzypp URLs.

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:



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

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:



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

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

#EscapeQuery(input) ⇒ String

Escape path part of URL string

Parameters:

  • input (String)

    input string

Returns:



36
37
38
# File 'library/types/src/modules/URLRecode.rb', line 36

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



44
45
46
# File 'library/types/src/modules/URLRecode.rb', line 44

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