From 49d542f6d32381c44721fd4a89e423d489c8bec7 Mon Sep 17 00:00:00 2001 From: nagachika Date: Tue, 9 Oct 2018 14:43:06 +0000 Subject: [PATCH] merge revision(s) 64860,64861: [Backport #15164] fallback env encoding to ASCII-8BIT * hash.c (env_enc_str_new): as no locale/filesystem encoding is available in miniruby on Windows, fallback the encoding to ASCII-8BIT so it is valid encoding when the conversion failed. [ruby-core:89177] [Bug #15164] * properties. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@64982 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- bootstraptest/test_env.rb | 12 ++++++++++++ hash.c | 2 +- version.h | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 bootstraptest/test_env.rb diff --git a/bootstraptest/test_env.rb b/bootstraptest/test_env.rb new file mode 100644 index 0000000000..7d1b45b75e --- /dev/null +++ b/bootstraptest/test_env.rb @@ -0,0 +1,12 @@ +assert_equal "true", %q{ + ENV["ENVTEST"] = "\u{e9 3042 d76c}" + env = ENV["ENVTEST"] + env.valid_encoding? +} + +# different encoding is used for PATH +assert_equal "true", %q{ + ENV["PATH"] = "\u{e9 3042 d76c}" + env = ENV["PATH"] + env.valid_encoding? +} diff --git a/hash.c b/hash.c index b434671336..0a9a5ee261 100644 --- a/hash.c +++ b/hash.c @@ -3262,7 +3262,7 @@ env_enc_str_new(const char *ptr, long len, rb_encoding *enc) rb_encoding *utf8 = rb_utf8_encoding(); VALUE str = rb_enc_str_new(NULL, 0, (internal ? internal : enc)); if (NIL_P(rb_str_cat_conv_enc_opts(str, 0, ptr, len, utf8, ecflags, Qnil))) { - rb_str_initialize(str, ptr, len, utf8); + rb_str_initialize(str, ptr, len, NULL); } #else VALUE str = rb_external_str_new_with_enc(ptr, len, enc); diff --git a/version.h b/version.h index ab889d80ce..b01479fe1f 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.5.2" #define RUBY_RELEASE_DATE "2018-10-09" -#define RUBY_PATCHLEVEL 95 +#define RUBY_PATCHLEVEL 96 #define RUBY_RELEASE_YEAR 2018 #define RUBY_RELEASE_MONTH 10