mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* string.c (rb_str_intern): allow symbols to contains nul.
* string.c (sym_inspect): symbol may contain nul. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10919 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
96a8a44317
commit
e6340674d1
2 changed files with 8 additions and 5 deletions
|
@ -2,6 +2,10 @@ Wed Sep 13 16:43:36 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* string.c (rb_str_intern): prohibit interning tainted string.
|
* string.c (rb_str_intern): prohibit interning tainted string.
|
||||||
|
|
||||||
|
* string.c (rb_str_intern): allow symbols to contains nul.
|
||||||
|
|
||||||
|
* string.c (sym_inspect): symbol may contain nul.
|
||||||
|
|
||||||
Wed Sep 13 01:14:02 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Wed Sep 13 01:14:02 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* lib/optparse.rb (OptionParser#getopts): works with pre-registered
|
* lib/optparse.rb (OptionParser#getopts): works with pre-registered
|
||||||
|
|
9
string.c
9
string.c
|
@ -4151,12 +4151,10 @@ rb_str_intern(VALUE s)
|
||||||
if (!RSTRING_PTR(str) || RSTRING_LEN(str) == 0) {
|
if (!RSTRING_PTR(str) || RSTRING_LEN(str) == 0) {
|
||||||
rb_raise(rb_eArgError, "interning empty string");
|
rb_raise(rb_eArgError, "interning empty string");
|
||||||
}
|
}
|
||||||
if (strlen(RSTRING_PTR(str)) != RSTRING_LEN(str))
|
|
||||||
rb_raise(rb_eArgError, "symbol string may not contain `\\0'");
|
|
||||||
if (OBJ_TAINTED(str)) {
|
if (OBJ_TAINTED(str)) {
|
||||||
rb_raise(rb_eSecurityError, "Insecure: can't intern tainted string");
|
rb_raise(rb_eSecurityError, "Insecure: can't intern tainted string");
|
||||||
}
|
}
|
||||||
id = rb_intern(RSTRING_PTR(str));
|
id = rb_intern2(RSTRING_PTR(str), RSTRING_LEN(str));
|
||||||
return ID2SYM(id);
|
return ID2SYM(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4482,7 +4480,8 @@ sym_inspect(VALUE sym)
|
||||||
str = rb_str_new(0, RSTRING_LEN(sym)+1);
|
str = rb_str_new(0, RSTRING_LEN(sym)+1);
|
||||||
RSTRING_PTR(str)[0] = ':';
|
RSTRING_PTR(str)[0] = ':';
|
||||||
memcpy(RSTRING_PTR(str)+1, RSTRING_PTR(sym), RSTRING_LEN(sym));
|
memcpy(RSTRING_PTR(str)+1, RSTRING_PTR(sym), RSTRING_LEN(sym));
|
||||||
if (!rb_symname_p(RSTRING_PTR(sym))) {
|
if (RSTRING_LEN(sym) != strlen(RSTRING_PTR(sym)) ||
|
||||||
|
!rb_symname_p(RSTRING_PTR(sym))) {
|
||||||
str = rb_str_dump(str);
|
str = rb_str_dump(str);
|
||||||
strncpy(RSTRING_PTR(str), ":\"", 2);
|
strncpy(RSTRING_PTR(str), ":\"", 2);
|
||||||
}
|
}
|
||||||
|
@ -4580,7 +4579,7 @@ rb_to_id(VALUE name)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case T_SYMBOL:
|
case T_SYMBOL:
|
||||||
id = SYM2ID(name);
|
return SYM2ID(name);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
tmp = rb_check_string_type(name);
|
tmp = rb_check_string_type(name);
|
||||||
|
|
Loading…
Add table
Reference in a new issue