mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
parse.y: symbol names must be ascii-compatible
* parse.y (rb_enc_symname_type): encoding of symbol names must be ascii-compatible, reject ascii-incompatible encodings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44836 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c5038b22eb
commit
e10e309dce
2 changed files with 6 additions and 0 deletions
1
parse.y
1
parse.y
|
@ -10231,6 +10231,7 @@ rb_enc_symname_type(const char *name, long len, rb_encoding *enc, unsigned int a
|
|||
const char *e = m + len;
|
||||
int type = ID_JUNK;
|
||||
|
||||
if (!rb_enc_asciicompat(enc)) return -1;
|
||||
if (!m || len <= 0) return -1;
|
||||
switch (*m) {
|
||||
case '\0':
|
||||
|
|
|
@ -651,6 +651,11 @@ class TestModule < Test::Unit::TestCase
|
|||
assert_raise(NameError) { c1.const_set(:foo, :foo) }
|
||||
assert_raise(NameError) { c1.const_set("bar", :foo) }
|
||||
assert_raise(TypeError) { c1.const_set(1, :foo) }
|
||||
assert_nothing_raised(NameError) { c1.const_set("X\u{3042}", :foo) }
|
||||
assert_raise(NameError) { c1.const_set("X\u{3042}".encode("utf-16be"), :foo) }
|
||||
assert_raise(NameError) { c1.const_set("X\u{3042}".encode("utf-16le"), :foo) }
|
||||
assert_raise(NameError) { c1.const_set("X\u{3042}".encode("utf-32be"), :foo) }
|
||||
assert_raise(NameError) { c1.const_set("X\u{3042}".encode("utf-32le"), :foo) }
|
||||
end
|
||||
|
||||
def test_const_get_invalid_name
|
||||
|
|
Loading…
Reference in a new issue