* string.c (rb_str_intern): raise SecurityError only when $SAFE
level is greater than zero. [ruby-core:08862] * parse.y (rb_interned_p): new function to check if a string is already interned. * string.c (str_to_id): use rb_str_intern(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10932 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
803cabaced
commit
23d2c8b624
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
Thu Sep 14 16:11:15 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* string.c (rb_str_intern): raise SecurityError only when $SAFE
|
||||||
|
level is greater than zero. [ruby-core:08862]
|
||||||
|
|
||||||
|
* parse.y (rb_interned_p): new function to check if a string is
|
||||||
|
already interned.
|
||||||
|
|
||||||
|
* string.c (str_to_id): use rb_str_intern().
|
||||||
|
|
||||||
Thu Sep 14 14:37:45 2006 Tanaka Akira <akr@fsij.org>
|
Thu Sep 14 14:37:45 2006 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* ext/digest/lib/digest.rb (Digest::Base.file): new method.
|
* ext/digest/lib/digest.rb (Digest::Base.file): new method.
|
||||||
|
|
1
intern.h
1
intern.h
|
@ -400,6 +400,7 @@ int rb_is_class_id(ID);
|
||||||
int rb_is_local_id(ID);
|
int rb_is_local_id(ID);
|
||||||
int rb_is_junk_id(ID);
|
int rb_is_junk_id(ID);
|
||||||
int rb_symname_p(const char*);
|
int rb_symname_p(const char*);
|
||||||
|
int rb_sym_interned_p(VALUE);
|
||||||
VALUE rb_backref_get(void);
|
VALUE rb_backref_get(void);
|
||||||
void rb_backref_set(VALUE);
|
void rb_backref_set(VALUE);
|
||||||
VALUE rb_lastline_get(void);
|
VALUE rb_lastline_get(void);
|
||||||
|
|
11
parse.y
11
parse.y
|
@ -8381,6 +8381,17 @@ rb_symname_p(const char *name)
|
||||||
return *m ? Qfalse : Qtrue;
|
return *m ? Qfalse : Qtrue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
rb_sym_interned_p(str)
|
||||||
|
VALUE str;
|
||||||
|
{
|
||||||
|
ID id;
|
||||||
|
|
||||||
|
if (st_lookup(global_symbols.sym_id, (st_data_t)str, (st_data_t *)&id))
|
||||||
|
return Qtrue;
|
||||||
|
return Qfalse;
|
||||||
|
}
|
||||||
|
|
||||||
ID
|
ID
|
||||||
rb_intern2(const char *name, long len)
|
rb_intern2(const char *name, long len)
|
||||||
{
|
{
|
||||||
|
|
8
string.c
8
string.c
|
@ -4151,7 +4151,7 @@ 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 (OBJ_TAINTED(str)) {
|
if (OBJ_TAINTED(str) && rb_safe_level() >= 1 && !rb_sym_interned_p(str)) {
|
||||||
rb_raise(rb_eSecurityError, "Insecure: can't intern tainted string");
|
rb_raise(rb_eSecurityError, "Insecure: can't intern tainted string");
|
||||||
}
|
}
|
||||||
id = rb_intern2(RSTRING_PTR(str), RSTRING_LEN(str));
|
id = rb_intern2(RSTRING_PTR(str), RSTRING_LEN(str));
|
||||||
|
@ -4556,10 +4556,8 @@ sym_to_proc(VALUE sym)
|
||||||
static ID
|
static ID
|
||||||
str_to_id(VALUE str)
|
str_to_id(VALUE str)
|
||||||
{
|
{
|
||||||
if (!RSTRING_PTR(str) || RSTRING_LEN(str) == 0) {
|
VALUE sym = rb_str_intern(str);
|
||||||
rb_raise(rb_eArgError, "empty symbol string");
|
return SYM2ID(sym);
|
||||||
}
|
|
||||||
return rb_intern2(RSTRING_PTR(str), RSTRING_LEN(str));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ID
|
ID
|
||||||
|
|
Loading…
Reference in New Issue