From e6340674d16049c9d93270d00a93941abe557e64 Mon Sep 17 00:00:00 2001 From: matz Date: Wed, 13 Sep 2006 08:19:54 +0000 Subject: * 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 --- string.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'string.c') diff --git a/string.c b/string.c index 332b6186dd..43d4f40747 100644 --- a/string.c +++ b/string.c @@ -4151,12 +4151,10 @@ rb_str_intern(VALUE s) if (!RSTRING_PTR(str) || RSTRING_LEN(str) == 0) { 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)) { 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); } @@ -4482,7 +4480,8 @@ sym_inspect(VALUE sym) str = rb_str_new(0, RSTRING_LEN(sym)+1); RSTRING_PTR(str)[0] = ':'; 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); strncpy(RSTRING_PTR(str), ":\"", 2); } @@ -4580,7 +4579,7 @@ rb_to_id(VALUE name) } break; case T_SYMBOL: - id = SYM2ID(name); + return SYM2ID(name); break; default: tmp = rb_check_string_type(name); -- cgit v1.2.3