Module: ERB::Escape
- Included in:
- Util
- Defined in:
- lib/erb/util.rb,
ext/erb/escape/escape.c
Overview
ERB::Escape
A subset of ERB::Util. Unlike ERB::Util#html_escape, we expect/hope Rails will not monkey-patch ERB::Escape#html_escape.
Class Method Summary collapse
-
.html_escape(s) ⇒ Object
ERB::Util.html_escape is similar to CGI.escapeHTML but different in the following two parts:.
Class Method Details
.html_escape(s) ⇒ Object
ERB::Util.html_escape is similar to CGI.escapeHTML but different in the following two parts:
-
ERB::Util.html_escape converts an argument with #to_s first (only if it’s not T_STRING)
-
ERB::Util.html_escape does not allocate a new string when nothing needs to be escaped
74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'ext/erb/escape/escape.c', line 74
static VALUE
erb_escape_html(VALUE self, VALUE str)
{
if (!RB_TYPE_P(str, T_STRING)) {
str = rb_convert_type(str, T_STRING, "String", "to_s");
}
if (rb_enc_str_asciicompat_p(str)) {
return optimized_escape_html(str);
}
else {
return rb_funcall(rb_cCGI, id_escapeHTML, 1, str);
}
}
|