summaryrefslogtreecommitdiff
path: root/object.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-14 03:38:22 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-14 03:38:22 +0000
commita370556cd289ee8bffaca769328c3d0de0928af2 (patch)
treecaff848a475e5a67dac91bc279ac355d33ce734d /object.c
parent1e4a9554358d15dd00fbb2edeb0bf80866d7b7c4 (diff)
object.c: check const names
* object.c (rb_mod_const_get, rb_mod_const_defined): check constant names more strictly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'object.c')
-rw-r--r--object.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/object.c b/object.c
index 9b8ca74..81c5c56 100644
--- a/object.c
+++ b/object.c
@@ -2134,16 +2134,16 @@ rb_mod_const_get(int argc, VALUE *argv, VALUE mod)
}
if (!id) {
- if (!ISUPPER(*pbeg) || !rb_enc_symname2_p(pbeg, len, enc)) {
- part = rb_str_subseq(name, beglen, len);
+ part = rb_str_subseq(name, beglen, len);
+ OBJ_FREEZE(part);
+ if (!ISUPPER(*pbeg) || !rb_is_const_name(part)) {
rb_name_error_str(part, "wrong constant name %"PRIsVALUE,
QUOTE(part));
}
else if (!rb_method_basic_definition_p(CLASS_OF(mod), id_const_missing)) {
- id = rb_intern3(pbeg, len, enc);
+ id = rb_intern_str(part);
}
else {
- part = rb_str_subseq(name, beglen, len);
rb_name_error_str(part, "uninitialized constant %"PRIsVALUE"%"PRIsVALUE,
rb_str_subseq(name, 0, beglen),
QUOTE(part));
@@ -2271,8 +2271,9 @@ rb_mod_const_defined(int argc, VALUE *argv, VALUE mod)
}
if (!id) {
- if (!ISUPPER(*pbeg) || !rb_enc_symname2_p(pbeg, len, enc)) {
- part = rb_str_subseq(name, beglen, len);
+ part = rb_str_subseq(name, beglen, len);
+ OBJ_FREEZE(part);
+ if (!ISUPPER(*pbeg) || !rb_is_const_name(part)) {
rb_name_error_str(part, "wrong constant name %"PRIsVALUE,
QUOTE(part));
}