Sha256: 8b11a387822516e5a31816c3d41c906b766e59c60e380ede2973d1e8a94ac468
Contents?: true
Size: 827 Bytes
Versions: 12
Compression:
Stored size: 827 Bytes
Contents
class String def json_escape ERB::Util.json_escape self end HTML_ESCAPE_MAP = { '&' => '&', '>' => '>', '<' => '<', '"' => '"' } def html_escape # ERB and Rack both are replacing '/' character, and it's wrong because it destroys links (like '/default/my_item') # ERB::Util.html_escape self # Rack::Utils.escape_html self gsub(/[&"><]/){|special| HTML_ESCAPE_MAP[special]} end def url_escape CGI.escape self end JS_ESCAPE_MAP = { '\\' => '\\\\', '</' => '<\/', "\r\n" => '\n', "\n" => '\n', "\r" => '\n', '"' => '\\"', "'" => "\\'" } def js_escape gsub(/(\\|<\/|\r\n|[\n\r"'])/){JS_ESCAPE_MAP[$1]} end # String marks, like :format, :safe def marks; @marks ||= OpenObject.new end end
Version data entries
12 entries across 12 versions & 1 rubygems