module EscapeUtils

Constants

VERSION

Attributes

html_safe_string_class[R]

Default String class to return from HTML escaping

Public Class Methods

escape_html(html, secure = false) click to toggle source
# File lib/escape_utils.rb, line 42
def self.escape_html(html, secure = false)
  warn "EscapeUtils.escape_html is deprecated. Use GCI.escapeHTML instead, it's faster"
  CGI.escapeHTML(html)
end
escape_html_as_html_safe(html) click to toggle source
# File lib/escape_utils.rb, line 47
def self.escape_html_as_html_safe(html)
  warn "EscapeUtils.escape_html_as_html_safe is deprecated. Use GCI.escapeHTML(str).html_safe instead, it's faster"

  escaped = CGI.escapeHTML(html)
  if String == @html_safe_string_class
    escaped
  else
    escaped = @html_safe_string_class.new(escaped)
    escaped.instance_variable_set(:@html_safe, true)
    escaped
  end
end
escape_html_once_as_html_safe(html) click to toggle source
# File lib/escape_utils.rb, line 31
def self.escape_html_once_as_html_safe(html)
  escaped = escape_html_once(html)
  if String == @html_safe_string_class
    escaped
  else
    escaped = @html_safe_string_class.new(escaped)
    escaped.instance_variable_set(:@html_safe, true)
    escaped
  end
end
escape_url(string) click to toggle source
# File lib/escape_utils.rb, line 65
def self.escape_url(string)
  warn "EscapeUtils.escape_url is deprecated. Use CGI.escape instead, performance is similar"
  CGI.escape(string)
end
unescape_html(html) click to toggle source
# File lib/escape_utils.rb, line 60
def self.unescape_html(html)
  warn "EscapeUtils.unescape_html is deprecated. Use GCI.unescapeHTML instead, performance is similar"
  CGI.unescapeHTML(html)
end
unescape_url(string) click to toggle source
# File lib/escape_utils.rb, line 70
def self.unescape_url(string)
  warn "EscapeUtils.unescape_url is deprecated. Use CGI.unescape instead, performance is similar"
  CGI.unescape(string)
end

Public Instance Methods

escape_html_once(p1) click to toggle source

HTML methods

static VALUE rb_eu_escape_html_once(VALUE self, VALUE str)
{
        gh_buf buf = GH_BUF_INIT;
        Check_Type(str, T_STRING);
        check_utf8_encoding(str);

        if (houdini_escape_html_once(&buf, (const uint8_t *)RSTRING_PTR(str), RSTRING_LEN(str))) {
                VALUE result = rb_utf8_str_new(buf.ptr, buf.size);
                gh_buf_free(&buf);
                return result;
        }

        return str;
}
escape_javascript(p1) click to toggle source

JavaScript methods

static VALUE rb_eu_escape_js(VALUE self, VALUE str)
{
        return rb_eu__generic(rb_obj_as_string(str), &houdini_escape_js);
}
escape_uri(p1) click to toggle source

URI methods

static VALUE rb_eu_escape_uri(VALUE self, VALUE str)
{
        return rb_eu__generic(str, &houdini_escape_uri);
}
escape_uri_component(p1) click to toggle source

URI component methods

static VALUE rb_eu_escape_uri_component(VALUE self, VALUE str)
{
        return rb_eu__generic(str, &houdini_escape_uri_component);
}
escape_xml(p1) click to toggle source

XML methods

static VALUE rb_eu_escape_xml(VALUE self, VALUE str)
{
        return rb_eu__generic(str, &houdini_escape_xml);
}
html_safe_string_class=(klass) click to toggle source
# File lib/escape_utils.rb, line 20
def html_safe_string_class=(klass)
  unless String >= klass
    raise ArgumentError, "EscapeUtils.html_safe_string_class must inherit from ::String"
  end
  @html_safe_string_class = klass
end
html_secure() click to toggle source
# File lib/escape_utils.rb, line 8
def html_secure
  warn "EscapeUtils.html_secure is deprecated"
  false
end
html_secure=(val) click to toggle source
# File lib/escape_utils.rb, line 13
def html_secure=(val)
  warn "EscapeUtils.html_secure is deprecated"
end
unescape_javascript(p1) click to toggle source
static VALUE rb_eu_unescape_js(VALUE self, VALUE str)
{
        return rb_eu__generic(str, &houdini_unescape_js);
}
unescape_uri(p1) click to toggle source
static VALUE rb_eu_unescape_uri(VALUE self, VALUE str)
{
        return rb_eu__generic(str, &houdini_unescape_uri);
}
unescape_uri_component(p1) click to toggle source
static VALUE rb_eu_unescape_uri_component(VALUE self, VALUE str)
{
        return rb_eu__generic(str, &houdini_unescape_uri_component);
}