/usr/lib/ruby/1.8/ramaze/snippets/string/esc.rb is in libramaze-ruby1.8 2010.06.18-2.
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 | require 'cgi'
require 'uri'
module Ramaze
module CoreExtensions
# Extensions for String
module String
# String#escape is an extensible escaping mechanism for string. currently
# it suports
# '<div>foo bar</div>'.esc(:html)
# 'foo bar'.esc(:uri)
# 'foo bar'.esc(:cgi)
def escape which = :html
case which
when :html
Rack::Utils.escape_html(self)
when :cgi
Rack::Utils.escape(self)
when :uri
::URI.escape(self)
else
raise ArgumentError, "do not know how to escape '#{ which }'"
end
end
alias_method 'esc', 'escape'
end
end
end
|