module CGI::Escape
Web-related escape/unescape functionality.
Public Instance Methods
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/cgi-escape/0/escape.rbs, line 32
def escape: (string str) -> String
URL-encode a string into application/x-www-form-urlencoded. Space characters (" ") are encoded with plus signs ("+") url_encoded_string = CGI.escape(“‘Stop!’ said Fred”) # => “%27Stop%21%27+said+Fred”
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/cgi-escape/0/escape.rbs, line 52
def escapeElement: (string string, *String | Array[String] elements) -> String
Escape only the tags of certain HTML elements in string.
Takes an element or elements or array of elements. Each element is specified by the name of the element, without angle brackets. This matches both the start and the end tag of that element. The attribute list of the open tag will also be escaped (for instance, the double-quotes surrounding attribute values).
print CGI.escapeElement('<BR><A HREF="url"></A>', "A", "IMG") # "<BR><A HREF="url"></A>" print CGI.escapeElement('<BR><A HREF="url"></A>', ["A", "IMG"]) # "<BR><A HREF="url"></A>"
(string str) → String
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/cgi-escape/0/escape.rbs, line 62
def escapeHTML: (string str) -> String
Escape special characters in HTML, namely '&\"<> CGI.escapeHTML(‘Usage: foo “bar” <baz>’) # => “Usage: foo ”bar“ <baz>”
(string) → String
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/cgi-escape/0/escape.rbs, line 73
def escapeURIComponent: (string) -> String
URL-encode a string following RFC 3986 Space characters (" ") are encoded with ("%20") url_encoded_string = CGI.escapeURIComponent(“‘Stop!’ said Fred”) # => “%27Stop%21%27%20said%20Fred”
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/cgi-escape/0/escape.rbs, line 112
def unescape: (string str, ?encoding encoding) -> String
URL-decode an application/x-www-form-urlencoded string with encoding(optional). string = CGI.unescape(“%27Stop%21%27+said+Fred”) # => “‘Stop!’ said Fred”
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/cgi-escape/0/escape.rbs, line 128
def unescapeElement: (string string, *String | Array[String] elements) -> String
Undo escaping such as that done by CGI.escapeElement
print CGI.unescapeElement( CGI.escapeHTML('<BR><A HREF="url"></A>'), "A", "IMG") # "<BR><A HREF="url"></A>" print CGI.unescapeElement( CGI.escapeHTML('<BR><A HREF="url"></A>'), ["A", "IMG"]) # "<BR><A HREF="url"></A>"
(string str) → String
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/cgi-escape/0/escape.rbs, line 138
def unescapeHTML: (string str) -> String
Unescape a string that has been HTML-escaped CGI.unescapeHTML(“Usage: foo ”bar“ <baz>”) # => “Usage: foo \"bar\” <baz>“
(string) → String
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/cgi-escape/0/escape.rbs, line 148
def unescapeURIComponent: (string) -> String
URL-decode a string following RFC 3986 with encoding(optional). string = CGI.unescapeURIComponent(“%27Stop%21%27+said%20Fred”) # => “‘Stop!’+said Fred”