зеркало из https://github.com/github/ruby.git
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:
Родитель
6a35c26b2d
Коммит
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>
|
||||
|
||||
* 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);
|
||||
}
|
||||
|
||||
if (p[0] == ':' && p[1] == ':') {
|
||||
if (p + 2 < pend && p[0] == ':' && p[1] == ':') {
|
||||
mod = rb_cObject;
|
||||
p += 2;
|
||||
pbeg = p;
|
||||
|
@ -1981,8 +1981,8 @@ rb_mod_const_get(int argc, VALUE *argv, VALUE mod)
|
|||
else {
|
||||
part = rb_str_subseq(name, pbeg-path, p-pbeg);
|
||||
}
|
||||
if (p[0] == ':') {
|
||||
if (p[1] != ':') {
|
||||
if (p < pend && p[0] == ':') {
|
||||
if (p + 2 >= pend || p[1] != ':') {
|
||||
rb_raise(rb_eNameError, "wrong constant name %s", path);
|
||||
}
|
||||
p += 2;
|
||||
|
|
|
@ -246,8 +246,9 @@ class TestModule < Test::Unit::TestCase
|
|||
":Object",
|
||||
"",
|
||||
":",
|
||||
].each do |name|
|
||||
e = assert_raises(NameError) {
|
||||
["String::", "[Bug #7573]"],
|
||||
].each do |name, msg|
|
||||
e = assert_raises(NameError, "#{msg}#{': ' if msg}wrong constant name #{name.dump}") {
|
||||
Object.const_get name
|
||||
}
|
||||
assert_equal("wrong constant name %s" % name, e.message)
|
||||
|
|
Загрузка…
Ссылка в новой задаче