object.c: check more strictly
* object.c (rb_mod_const_get): check more strictly. [ruby-dev:46748] [Bug #7573] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38551 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
6a35c26b2d
commit
af1ca4cb13
@ -1,3 +1,8 @@
|
|||||||
|
Sat Dec 22 19:26:35 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* object.c (rb_mod_const_get): check more strictly. [ruby-dev:46748]
|
||||||
|
[Bug #7573]
|
||||||
|
|
||||||
Wed Dec 19 02:34:48 2012 CHIKANAGA Tomoyuki <nagachika@ruby-lang.org>
|
Wed Dec 19 02:34:48 2012 CHIKANAGA Tomoyuki <nagachika@ruby-lang.org>
|
||||||
|
|
||||||
* cont.c (rb_fiber_start): in case of jump with TAG_FATAL,
|
* cont.c (rb_fiber_start): in case of jump with TAG_FATAL,
|
||||||
|
6
object.c
6
object.c
@ -1959,7 +1959,7 @@ rb_mod_const_get(int argc, VALUE *argv, VALUE mod)
|
|||||||
rb_raise(rb_eNameError, "wrong constant name %s", path);
|
rb_raise(rb_eNameError, "wrong constant name %s", path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p[0] == ':' && p[1] == ':') {
|
if (p + 2 < pend && p[0] == ':' && p[1] == ':') {
|
||||||
mod = rb_cObject;
|
mod = rb_cObject;
|
||||||
p += 2;
|
p += 2;
|
||||||
pbeg = p;
|
pbeg = p;
|
||||||
@ -1981,8 +1981,8 @@ rb_mod_const_get(int argc, VALUE *argv, VALUE mod)
|
|||||||
else {
|
else {
|
||||||
part = rb_str_subseq(name, pbeg-path, p-pbeg);
|
part = rb_str_subseq(name, pbeg-path, p-pbeg);
|
||||||
}
|
}
|
||||||
if (p[0] == ':') {
|
if (p < pend && p[0] == ':') {
|
||||||
if (p[1] != ':') {
|
if (p + 2 >= pend || p[1] != ':') {
|
||||||
rb_raise(rb_eNameError, "wrong constant name %s", path);
|
rb_raise(rb_eNameError, "wrong constant name %s", path);
|
||||||
}
|
}
|
||||||
p += 2;
|
p += 2;
|
||||||
|
@ -246,8 +246,9 @@ class TestModule < Test::Unit::TestCase
|
|||||||
":Object",
|
":Object",
|
||||||
"",
|
"",
|
||||||
":",
|
":",
|
||||||
].each do |name|
|
["String::", "[Bug #7573]"],
|
||||||
e = assert_raises(NameError) {
|
].each do |name, msg|
|
||||||
|
e = assert_raises(NameError, "#{msg}#{': ' if msg}wrong constant name #{name.dump}") {
|
||||||
Object.const_get name
|
Object.const_get name
|
||||||
}
|
}
|
||||||
assert_equal("wrong constant name %s" % name, e.message)
|
assert_equal("wrong constant name %s" % name, e.message)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user