diff options
author | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-05-02 23:18:55 +0000 |
---|---|---|
committer | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-05-02 23:18:55 +0000 |
commit | 395b7f2c31e3f2d15298bec2039ed1cc15fd8f56 (patch) | |
tree | 0cd94f371081a41c1f278ba397f90d21b6477d04 /test | |
parent | fa283ecac16fbbaf449517d2c5247c8db5ace477 (diff) | |
download | ruby-395b7f2c31e3f2d15298bec2039ed1cc15fd8f56.tar.gz |
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 'test')
-rw-r--r-- | test/cgi/test_cgi_util.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/cgi/test_cgi_util.rb b/test/cgi/test_cgi_util.rb index f2f5575efb..786e6f18a3 100644 --- a/test/cgi/test_cgi_util.rb +++ b/test/cgi/test_cgi_util.rb @@ -197,4 +197,25 @@ class CGIUtilTest < Test::Unit::TestCase assert_equal('<BR><A HREF="url"></A>', unescape_element(escapeHTML('<BR><A HREF="url"></A>'), "A", "IMG")) assert_equal('<BR><A HREF="url"></A>', unescape_element(escapeHTML('<BR><A HREF="url"></A>'), ["A", "IMG"])) end + + def test_escape_string_subclass + sc = Class.new(String).freeze + str = sc.new('>') + msg = '[ruby-core:86847] [Bug #14732]' + assert_not_instance_of String, str + + html = escapeHTML(str) + assert_instance_of sc, html, msg + assert_equal '>', html + orig = unescapeHTML(html) + assert_instance_of sc, orig, msg + assert_equal '>', orig + + url = escape(str) + assert_instance_of sc, url, msg + assert_equal '%3E', url + orig = unescape(url) + assert_instance_of sc, orig, msg + assert_equal '>', orig + end end |