/usr/lib/ruby/1.8/innate/helper/cgi.rb is in libinnate-ruby1.8 2010.07-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | autoload(:CGI, 'cgi') # in case you want to use html_unescape
module Innate
# Shortcuts to some CGI methods
module Helper
module CGI
module_function
# Shortcut for Rack::Utils.escape
#
# @param [#to_s] input
# @return [String] URI-encoded representation of +input+
def url_encode(input)
Rack::Utils.escape(input.to_s)
end
alias u url_encode
# Shortcut for Rack::Utils.unescape
#
# @param [#to_s] input
# @return [String] URI-decoded representation of +input+
def url_decode(input)
Rack::Utils.unescape(input.to_s)
end
# Shortcut for Rack::Utils.escape_html
#
# @param [#to_s] input
# @return [String]
def html_escape(input)
Rack::Utils.escape_html(input.to_s)
end
# Shortcut for CGI.unescapeHTML
#
# @param [#to_s] input
# @return [String]
def html_unescape(input)
::CGI.unescapeHTML(input.to_s)
end
# safely escape all HTML and code
def html_and_code_escape(input)
Rack::Utils.escape_html(input.to_s).gsub(/#([{@$]@?)/, '#\1')
end
alias h html_and_code_escape
# aliases are ignored by module_function...
module_function :u, :h
end
end
end
|