summaryrefslogtreecommitdiff
path: root/lib/cgi
diff options
context:
space:
mode:
Diffstat (limited to 'lib/cgi')
-rw-r--r--lib/cgi/cookie.rb2
-rw-r--r--lib/cgi/core.rb10
-rw-r--r--lib/cgi/html.rb6
-rw-r--r--lib/cgi/session.rb4
-rw-r--r--lib/cgi/util.rb38
5 files changed, 30 insertions, 30 deletions
diff --git a/lib/cgi/cookie.rb b/lib/cgi/cookie.rb
index 9a0d41e2b8..5033357ab6 100644
--- a/lib/cgi/cookie.rb
+++ b/lib/cgi/cookie.rb
@@ -146,7 +146,7 @@ class CGI
buf = "#{@name}=#{val}".dup
buf << "; domain=#{@domain}" if @domain
buf << "; path=#{@path}" if @path
- buf << "; expires=#{CGI::rfc1123_date(@expires)}" if @expires
+ buf << "; expires=#{CGI.rfc1123_date(@expires)}" if @expires
buf << "; secure" if @secure
buf << "; HttpOnly" if @httponly
buf
diff --git a/lib/cgi/core.rb b/lib/cgi/core.rb
index c45f9b3a9e..ac0d2d3cb3 100644
--- a/lib/cgi/core.rb
+++ b/lib/cgi/core.rb
@@ -375,14 +375,14 @@ class CGI
# Parse an HTTP query string into a hash of key=>value pairs.
#
- # params = CGI::parse("query_string")
+ # params = CGI.parse("query_string")
# # {"name1" => ["value1", "value2", ...],
# # "name2" => ["value1", "value2", ...], ... }
#
- def CGI::parse(query)
+ def self.parse(query)
params = {}
query.split(/[&;]/).each do |pairs|
- key, value = pairs.split('=',2).collect{|v| CGI::unescape(v) }
+ key, value = pairs.split('=',2).collect{|v| CGI.unescape(v) }
next unless key
@@ -656,7 +656,7 @@ class CGI
@params = read_multipart(boundary, Integer(env_table['CONTENT_LENGTH']))
else
@multipart = false
- @params = CGI::parse(
+ @params = CGI.parse(
case env_table['REQUEST_METHOD']
when "GET", "HEAD"
if defined?(MOD_RUBY)
@@ -686,7 +686,7 @@ class CGI
end
end
- @cookies = CGI::Cookie::parse((env_table['HTTP_COOKIE'] or env_table['COOKIE']))
+ @cookies = CGI::Cookie.parse((env_table['HTTP_COOKIE'] or env_table['COOKIE']))
end
private :initialize_query
diff --git a/lib/cgi/html.rb b/lib/cgi/html.rb
index 02d847ebd3..1543943320 100644
--- a/lib/cgi/html.rb
+++ b/lib/cgi/html.rb
@@ -30,10 +30,10 @@ class CGI
attributes.each do|name, value|
next unless value
s << " "
- s << CGI::escapeHTML(name.to_s)
+ s << CGI.escapeHTML(name.to_s)
if value != true
s << '="'
- s << CGI::escapeHTML(value.to_s)
+ s << CGI.escapeHTML(value.to_s)
s << '"'
end
end
@@ -423,7 +423,7 @@ class CGI
buf << super(attributes)
if pretty
- CGI::pretty(buf, pretty)
+ CGI.pretty(buf, pretty)
else
buf
end
diff --git a/lib/cgi/session.rb b/lib/cgi/session.rb
index 5afc7e69aa..29e7b3ece3 100644
--- a/lib/cgi/session.rb
+++ b/lib/cgi/session.rb
@@ -403,7 +403,7 @@ class CGI
for line in f
line.chomp!
k, v = line.split('=',2)
- @hash[CGI::unescape(k)] = Marshal.restore(CGI::unescape(v))
+ @hash[CGI.unescape(k)] = Marshal.restore(CGI.unescape(v))
end
ensure
f&.close
@@ -421,7 +421,7 @@ class CGI
lockf.flock File::LOCK_EX
f = File.open(@path+".new", File::CREAT|File::TRUNC|File::WRONLY, 0600)
for k,v in @hash
- f.printf "%s=%s\n", CGI::escape(k), CGI::escape(String(Marshal.dump(v)))
+ f.printf "%s=%s\n", CGI.escape(k), CGI.escape(String(Marshal.dump(v)))
end
f.close
File.rename @path+".new", @path
diff --git a/lib/cgi/util.rb b/lib/cgi/util.rb
index 464115262f..aab8b000cb 100644
--- a/lib/cgi/util.rb
+++ b/lib/cgi/util.rb
@@ -7,7 +7,7 @@ end
module CGI::Util
@@accept_charset="UTF-8" unless defined?(@@accept_charset)
# URL-encode a string.
- # url_encoded_string = CGI::escape("'Stop!' said Fred")
+ # url_encoded_string = CGI.escape("'Stop!' said Fred")
# # => "%27Stop%21%27+said+Fred"
def escape(string)
encoding = string.encoding
@@ -17,7 +17,7 @@ module CGI::Util
end
# URL-decode a string with encoding(optional).
- # string = CGI::unescape("%27Stop%21%27+said+Fred")
+ # string = CGI.unescape("%27Stop%21%27+said+Fred")
# # => "'Stop!' said Fred"
def unescape(string,encoding=@@accept_charset)
str=string.tr('+', ' ').b.gsub(/((?:%[0-9a-fA-F]{2})+)/) do |m|
@@ -36,7 +36,7 @@ module CGI::Util
}
# Escape special characters in HTML, namely '&\"<>
- # CGI::escapeHTML('Usage: foo "bar" <baz>')
+ # CGI.escapeHTML('Usage: foo "bar" <baz>')
# # => "Usage: foo &quot;bar&quot; &lt;baz&gt;"
def escapeHTML(string)
enc = string.encoding
@@ -60,7 +60,7 @@ module CGI::Util
end
# Unescape a string that has been HTML-escaped
- # CGI::unescapeHTML("Usage: foo &quot;bar&quot; &lt;baz&gt;")
+ # CGI.unescapeHTML("Usage: foo &quot;bar&quot; &lt;baz&gt;")
# # => "Usage: foo \"bar\" <baz>"
def unescapeHTML(string)
enc = string.encoding
@@ -118,10 +118,10 @@ module CGI::Util
end
end
- # Synonym for CGI::escapeHTML(str)
+ # Synonym for CGI.escapeHTML(str)
alias escape_html escapeHTML
- # Synonym for CGI::unescapeHTML(str)
+ # Synonym for CGI.unescapeHTML(str)
alias unescape_html unescapeHTML
# Escape only the tags of certain HTML elements in +string+.
@@ -132,30 +132,30 @@ module CGI::Util
# 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")
+ # print CGI.escapeElement('<BR><A HREF="url"></A>', "A", "IMG")
# # "<BR>&lt;A HREF=&quot;url&quot;&gt;&lt;/A&gt"
#
- # print CGI::escapeElement('<BR><A HREF="url"></A>', ["A", "IMG"])
+ # print CGI.escapeElement('<BR><A HREF="url"></A>', ["A", "IMG"])
# # "<BR>&lt;A HREF=&quot;url&quot;&gt;&lt;/A&gt"
def escapeElement(string, *elements)
elements = elements[0] if elements[0].kind_of?(Array)
unless elements.empty?
string.gsub(/<\/?(?:#{elements.join("|")})(?!\w)(?:.|\n)*?>/i) do
- CGI::escapeHTML($&)
+ CGI.escapeHTML($&)
end
else
string
end
end
- # Undo escaping such as that done by CGI::escapeElement()
+ # Undo escaping such as that done by CGI.escapeElement()
#
- # print CGI::unescapeElement(
- # CGI::escapeHTML('<BR><A HREF="url"></A>'), "A", "IMG")
+ # print CGI.unescapeElement(
+ # CGI.escapeHTML('<BR><A HREF="url"></A>'), "A", "IMG")
# # "&lt;BR&gt;<A HREF="url"></A>"
#
- # print CGI::unescapeElement(
- # CGI::escapeHTML('<BR><A HREF="url"></A>'), ["A", "IMG"])
+ # print CGI.unescapeElement(
+ # CGI.escapeHTML('<BR><A HREF="url"></A>'), ["A", "IMG"])
# # "&lt;BR&gt;<A HREF="url"></A>"
def unescapeElement(string, *elements)
elements = elements[0] if elements[0].kind_of?(Array)
@@ -168,10 +168,10 @@ module CGI::Util
end
end
- # Synonym for CGI::escapeElement(str)
+ # Synonym for CGI.escapeElement(str)
alias escape_element escapeElement
- # Synonym for CGI::unescapeElement(str)
+ # Synonym for CGI.unescapeElement(str)
alias unescape_element unescapeElement
# Abbreviated day-of-week names specified by RFC 822
@@ -182,7 +182,7 @@ module CGI::Util
# Format a +Time+ object as a String using the format specified by RFC 1123.
#
- # CGI::rfc1123_date(Time.now)
+ # CGI.rfc1123_date(Time.now)
# # Sat, 01 Jan 2000 00:00:00 GMT
def rfc1123_date(time)
t = time.clone.gmtime
@@ -196,13 +196,13 @@ module CGI::Util
# +string+ is the HTML string to indent. +shift+ is the indentation
# unit to use; it defaults to two spaces.
#
- # print CGI::pretty("<HTML><BODY></BODY></HTML>")
+ # print CGI.pretty("<HTML><BODY></BODY></HTML>")
# # <HTML>
# # <BODY>
# # </BODY>
# # </HTML>
#
- # print CGI::pretty("<HTML><BODY></BODY></HTML>", "\t")
+ # print CGI.pretty("<HTML><BODY></BODY></HTML>", "\t")
# # <HTML>
# # <BODY>
# # </BODY>