summaryrefslogtreecommitdiff
path: root/ext/cgi
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-05-02 23:18:55 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-05-02 23:18:55 +0000
commit6afea14043b0c0e603f26c89ae0d043f65852668 (patch)
tree0cd94f371081a41c1f278ba397f90d21b6477d04 /ext/cgi
parentd54e22860c895a4bb3e583a7ad9886b9ea518a77 (diff)
ext/cgi/escape: preserve String subclass in result
* ext/cgi/escape/escape.c (optimized_escape_html): use rb_str_new_with_class (optimized_unescape_html): ditto (optimized_escape): ditto (optimized_unescape): ditto * test/cgi/test_cgi_util.rb (test_escape_string_subclass): new test [ruby-core:86847] [Bug #14732] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63328 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/cgi')
-rw-r--r--ext/cgi/escape/escape.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/ext/cgi/escape/escape.c b/ext/cgi/escape/escape.c
index ced1b18..a36770b 100644
--- a/ext/cgi/escape/escape.c
+++ b/ext/cgi/escape/escape.c
@@ -59,7 +59,7 @@ optimized_escape_html(VALUE str)
case '<':
case '>':
if (!dest) {
- dest = rb_str_buf_new(len);
+ dest = rb_str_new_with_class(str, 0, 0);
}
rb_str_cat(dest, cstr + beg, i - beg);
@@ -151,7 +151,7 @@ optimized_unescape_html(VALUE str)
i += clen;
if (overflow || cc >= charlimit || cstr[i] != ';') continue;
if (!dest) {
- dest = rb_str_buf_new(len);
+ dest = rb_str_new_with_class(str, 0, 0);
}
rb_str_cat(dest, cstr + beg, plen);
if (charlimit > 256) {
@@ -168,7 +168,7 @@ optimized_unescape_html(VALUE str)
continue;
}
if (!dest) {
- dest = rb_str_buf_new(len);
+ dest = rb_str_new_with_class(str, 0, 0);
}
rb_str_cat(dest, cstr + beg, plen);
rb_str_cat(dest, &c, 1);
@@ -219,7 +219,7 @@ optimized_escape(VALUE str)
const unsigned char c = (unsigned char)cstr[i];
if (!url_unreserved_char(c)) {
if (!dest) {
- dest = rb_str_buf_new(len);
+ dest = rb_str_new_with_class(str, 0, 0);
}
rb_str_cat(dest, cstr + beg, i - beg);
@@ -278,7 +278,7 @@ optimized_unescape(VALUE str, VALUE encoding)
}
if (!dest) {
- dest = rb_str_buf_new(len);
+ dest = rb_str_new_with_class(str, 0, 0);
}
rb_str_cat(dest, cstr + beg, i - beg);