RAA - escape

escape / 0.2

Short description: URI/HTML/shell escaping utilities
Category: Library/Text
Status: experimental
Created: 2007-02-28 10:19:04 GMT
Last update: 2007-02-28 10:19:04 GMT
Owner: akr (Projects of this owner)
Homepage: http://www.a-k-r.org/escape/
Download: http://www.a-k-r.org/escape/
License: BSD
Dependency:
None
Description:

escape - HTML/URI/shell escaping utilities

escape library provides several HTML/URI/shell escaping functions.

Feature

  • several escaping/composing functions
    • HTML text
    • HTML attribute value
    • HTML form (x-www-form-urlencoded)
    • URI path
    • shell command line
  • dedicated classes for escaped strings
  • escape and compose strongly related strings at once

Usage

require 'escape'

Escape.shell_command(["echo", "*"]) #=> #<Escape::ShellEscaped: echo '*'>
Escape.uri_path("a?b/c?d/e?f") #=> #<Escape::PercentEncoded: a%3Fb/c%3Fd/e%3Ff>
Escape.html_form([["a","b"], ["c","d"]]) #=> #<Escape::PercentEncoded: a=b&c=d>
Escape.html_form({"a"=>"b", "c"=>"d"}) #=> #<Escape::PercentEncoded: a=b&c=d>
Escape.html_text("a & b < c > d") #=> #<Escape::HTMLEscaped: a &amp; b &lt; c &gt; d>
Escape.html_attr_value("ab&<>\"c") #=> #<Escape::HTMLAttrValue: "ab&amp;&lt;&gt;&quot;c">

Edit this project (for project owner)

back to RAA top