aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--parse.y1
-rw-r--r--test/ruby/test_module.rb5
2 files changed, 6 insertions, 0 deletions
diff --git a/parse.y b/parse.y
index 25946dccda..54b4c07da2 100644
--- a/parse.y
+++ b/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':
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb
index ba6f273159..57a01db28e 100644
--- a/test/ruby/test_module.rb
+++ b/test/ruby/test_module.rb
@@ -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