ruby-changes:32757
From: nobu <ko1@a...>
Date: Wed, 5 Feb 2014 15:49:39 +0900 (JST)
Subject: [ruby-changes:32757] nobu:r44836 (trunk): parse.y: symbol names must be ascii-compatible
nobu 2014-02-05 15:49:35 +0900 (Wed, 05 Feb 2014) New Revision: 44836 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44836 Log: 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. Modified files: trunk/parse.y trunk/test/ruby/test_module.rb Index: parse.y =================================================================== --- parse.y (revision 44835) +++ parse.y (revision 44836) @@ -10231,6 +10231,7 @@ rb_enc_symname_type(const char *name, lo https://github.com/ruby/ruby/blob/trunk/parse.y#L10231 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': Index: test/ruby/test_module.rb =================================================================== --- test/ruby/test_module.rb (revision 44835) +++ test/ruby/test_module.rb (revision 44836) @@ -651,6 +651,11 @@ class TestModule < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_module.rb#L651 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/