aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ext/erb/erb.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/ext/erb/erb.c b/ext/erb/erb.c
index 9376fa5dcb..4adab8ad33 100644
--- a/ext/erb/erb.c
+++ b/ext/erb/erb.c
@@ -55,18 +55,18 @@ optimized_escape_html(VALUE str)
}
}
- VALUE escaped;
+ VALUE escaped = str;
if (RSTRING_LEN(str) < (dest - buf)) {
escaped = rb_str_new(buf, dest - buf);
preserve_original_state(str, escaped);
}
- else {
- escaped = rb_str_dup(str);
- }
ALLOCV_END(vbuf);
return escaped;
}
+// ERB::Util.html_escape is different from CGI.escapeHTML 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
static VALUE
erb_escape_html(VALUE self, VALUE str)
{