diff options
| author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-09-13 08:19:54 +0000 |
|---|---|---|
| committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-09-13 08:19:54 +0000 |
| commit | c135614ed9a43ae3b0e9474e9adf04210125e10b (patch) | |
| tree | 4de1c5f9ac69b0be7a2da851e2513255bad03701 | |
| parent | 89014bb6e4d1fb3502efcbff0f5470c108d5bd44 (diff) | |
* string.c (rb_str_intern): allow symbols to contains nul.
* string.c (sym_inspect): symbol may contain nul.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@10919 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
| -rw-r--r-- | ChangeLog | 4 | ||||
| -rw-r--r-- | string.c | 9 |
2 files changed, 8 insertions, 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): 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> * lib/optparse.rb (OptionParser#getopts): works with pre-registered @@ -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); |
