mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
escape.c: check argument
* ext/cgi/escape/escape.c (optimized_unescape): check accept_charset encoding argument. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57501 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ffcb389d68
commit
c373866444
2 changed files with 8 additions and 1 deletions
|
@ -252,7 +252,8 @@ optimized_unescape(VALUE str, VALUE encoding)
|
|||
long i, len, beg = 0;
|
||||
VALUE dest = 0;
|
||||
const char *cstr;
|
||||
int cr, origenc, encidx = rb_to_encoding_index(encoding);
|
||||
rb_encoding *enc = rb_to_encoding(encoding);
|
||||
int cr, origenc, encidx = rb_enc_to_index(enc);
|
||||
|
||||
len = RSTRING_LEN(str);
|
||||
cstr = RSTRING_PTR(str);
|
||||
|
|
|
@ -56,6 +56,12 @@ class CGIUtilTest < Test::Unit::TestCase
|
|||
assert_equal(Encoding::UTF_8, CGI::unescape("%C0%3C%3C".force_encoding("UTF-8")).encoding)
|
||||
end
|
||||
|
||||
def test_cgi_unescape_accept_charset
|
||||
return unless defined?(::Encoding)
|
||||
|
||||
assert_raise(TypeError) {CGI.unescape('', nil)}
|
||||
end
|
||||
|
||||
def test_cgi_pretty
|
||||
assert_equal("<HTML>\n <BODY>\n </BODY>\n</HTML>\n",CGI::pretty("<HTML><BODY></BODY></HTML>"))
|
||||
assert_equal("<HTML>\n\t<BODY>\n\t</BODY>\n</HTML>\n",CGI::pretty("<HTML><BODY></BODY></HTML>","\t"))
|
||||
|
|
Loading…
Reference in a new issue