diff --git a/gems/cgi/0.5/_test/test.rb b/gems/cgi/0.5/_test/test.rb index 7fec9c5b..a24da7bb 100644 --- a/gems/cgi/0.5/_test/test.rb +++ b/gems/cgi/0.5/_test/test.rb @@ -5,4 +5,29 @@ cgi = CGI.new cgi.out("text/plain") { "string" } +CGI.escape("'Stop!' said Fred") #=> "%27Stop%21%27+said+Fred" +CGI.unescape("%27Stop%21%27+said+Fred") #=> "'Stop!' said Fred" + +CGI.escapeURIComponent("'Stop!' said Fred") #=> "%27Stop%21%27%20said%20Fred" +CGI.escape_uri_component("'Stop!' said Fred") #=> "%27Stop%21%27%20said%20Fred" + +CGI.unescapeURIComponent("%27Stop%21%27+said%20Fred") #=> "'Stop!'+said Fred" +CGI.unescape_uri_component("%27Stop%21%27+said%20Fred") #=> "'Stop!'+said Fred" + +CGI.escapeHTML('Usage: foo "bar" ') #=> "Usage: foo "bar" <baz>" +CGI.escape_html('Usage: foo "bar" ') #=> "Usage: foo "bar" <baz>" + +CGI.unescapeHTML("Usage: foo "bar" <baz>") #=> "Usage: foo \"bar\" " +CGI.unescape_html("Usage: foo "bar" <baz>") #=> "Usage: foo \"bar\" " + +CGI.escapeElement('
', "A", "IMG") #=> "
<A HREF="url"></A>" +CGI.escapeElement('
', ["A", "IMG"]) #=> "
<A HREF="url"></A>" +CGI.escape_element('
', "A", "IMG") #=> "
<A HREF="url"></A>" +CGI.escape_element('
', ["A", "IMG"]) #=> "
<A HREF="url"></A>" + +CGI.unescapeElement("
<A HREF="url"></A>", "A", "IMG") #=> "
"<BR>" +CGI.unescape_element("
<A HREF="url"></A>", "A", "IMG") #=> "
"<BR>" + cookies = CGI::Cookie.parse("raw_cookie_string") diff --git a/gems/cgi/0.5/core.rbs b/gems/cgi/0.5/core.rbs index 4c563f0d..2c16f01e 100644 --- a/gems/cgi/0.5/core.rbs +++ b/gems/cgi/0.5/core.rbs @@ -887,6 +887,26 @@ class CGI # def rfc1123_date: (Time time) -> String + def escape: (String) -> String + def unescape: (String, ?encoding: Encoding) -> String + + def escapeURIComponent: (String) -> String + def unescapeURIComponent: (String, ?encoding: Encoding) -> String + alias escape_uri_component escapeURIComponent + alias unescape_uri_component unescapeURIComponent + + def escapeHTML: (String) -> String + def unescapeHTML: (String) -> String + alias escape_html escapeHTML + alias unescape_html unescapeHTML + + def escapeElement: (String, *String) -> String + | (String, Array[String]) -> String + def unescapeElement: (String, *String) -> String + | (String, Array[String]) -> String + alias escape_element escapeElement + alias unescape_element unescapeElement + # Abbreviated day-of-week names specified by RFC 822 RFC822_DAYS: Array[String]