From 9e1b9b9c8f1bd72315466e66176559de58552e16 Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 4 Aug 2016 02:54:32 +0000 Subject: [PATCH] hash.c: set encoding * hash.c (env_assoc): the encoding of the value should be the locale, as well as other methods, [], fetch, values, etc. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55811 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ hash.c | 2 +- test/ruby/test_env.rb | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 132a23095a..762f61ed6e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Aug 4 11:54:30 2016 Nobuyoshi Nakada + + * hash.c (env_assoc): the encoding of the value should be the + locale, as well as other methods, [], fetch, values, etc. + Wed Aug 3 21:31:23 2016 Nobuyoshi Nakada * parse.y (reg_fragment_enc_error): compile_error is different diff --git a/hash.c b/hash.c index 963d9aed3f..d6bfc8a613 100644 --- a/hash.c +++ b/hash.c @@ -3899,7 +3899,7 @@ env_assoc(VALUE env, VALUE key) s = env_name(key); e = getenv(s); - if (e) return rb_assoc_new(key, rb_tainted_str_new2(e)); + if (e) return rb_assoc_new(key, env_str_new2(e)); return Qnil; } diff --git a/test/ruby/test_env.rb b/test/ruby/test_env.rb index 17323ccf95..77e83863c5 100644 --- a/test/ruby/test_env.rb +++ b/test/ruby/test_env.rb @@ -319,6 +319,8 @@ class TestEnv < Test::Unit::TestCase assert_equal("foo", v) end assert_invalid_env {|var| ENV.assoc(var)} + assert_predicate(v, :tainted?) + assert_equal(Encoding.find("locale"), v.encoding) end def test_has_value2