123456789_123456789_123456789_123456789_123456789_

Class: CGI

Relationships & Source Files
Namespace Children
Modules:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Escape, EscapeExt
Instance Chain:
self, Escape
Inherits: Object
Defined in: lib/cgi/escape.rb,
ext/cgi/escape/escape.c

Overview

Since Ruby 4.0, CGI is a small holder for various escaping methods, included from Escape

require 'cgi/escape'

CGI.escape("Ruby programming language")
#=> "Rubyprogramminglanguage"
CGI.escapeURIComponent("Ruby programming language")
#=> "Ruby%20programming%20language"

See Escape module for methods list and their description.

Constant Summary

Escape - Included

TABLE_FOR_ESCAPE_HTML__

Class Method Summary

Escape - Extended

escape

URL-encode a string into application/x-www-form-urlencoded.

escape_element
escape_html
escape_uri_component
escapeElement

Escape only the tags of certain HTML elements in string.

escapeHTML

Escape special characters in HTML, namely '&\"<>.

escapeURIComponent

URL-encode a string following RFC 3986 Space characters (" ") are encoded with ("%20").

h
unescape

URL-decode an application/x-www-form-urlencoded string with encoding(optional).

unescape_element
unescape_html
unescape_uri_component
unescapeElement

Undo escaping such as that done by CGI.escapeElement

unescapeHTML

Unescape a string that has been HTML-escaped.

unescapeURIComponent

URL-decode a string following RFC 3986 with encoding(optional).

EscapeExt - Extended

escape

Returns URL-escaped string (application/x-www-form-urlencoded).

escape_uri_component
escapeHTML

Returns HTML-escaped string.

escapeURIComponent

Returns URL-escaped string following RFC 3986.

unescape

Returns URL-unescaped string (application/x-www-form-urlencoded).

unescape_uri_component
unescapeHTML

Returns HTML-unescaped string.

unescapeURIComponent

Returns URL-unescaped string following RFC 3986.

Instance Method Summary

Escape - Included

#escape

URL-encode a string into application/x-www-form-urlencoded.

#escape_element
#escape_html
#escape_uri_component
#escapeElement

Escape only the tags of certain HTML elements in string.

#escapeHTML

Escape special characters in HTML, namely '&\"<>.

#escapeURIComponent

URL-encode a string following RFC 3986 Space characters (" ") are encoded with ("%20").

#h
#unescape

URL-decode an application/x-www-form-urlencoded string with encoding(optional).

#unescape_element
#unescape_html
#unescape_uri_component
#unescapeElement

Undo escaping such as that done by CGI.escapeElement

#unescapeHTML

Unescape a string that has been HTML-escaped.

#unescapeURIComponent

URL-decode a string following RFC 3986 with encoding(optional).