diff options
| -rw-r--r-- | ChangeLog | 20 | ||||
| -rw-r--r-- | load.c | 6 | ||||
| -rw-r--r-- | test/ruby/test_require.rb | 23 | ||||
| -rw-r--r-- | version.h | 2 |
4 files changed, 47 insertions, 4 deletions
@@ -1,3 +1,23 @@ +Sun Apr 21 00:14:36 2013 Kazuhiro NISHIYAMA <zn@mbf.nifty.com> + + * test/ruby/test_require.rb (TestRequire#test_require_nonascii_path): + RUBY_PLATFORM should escape as Regexp, + because RUBY_PLATFORM may contain '.'. + +Sun Apr 21 00:14:36 2013 Hiroshi Shirosaki <h.shirosaki@gmail.com> + + * test/ruby/test_require.rb (TestRequire#test_require_nonascii_path): + fix load path for encoding to run the test as stand-alone. + +Sun Apr 21 00:14:36 2013 Hiroshi Shirosaki <h.shirosaki@gmail.com> + + * load.c (features_index_add): use rb_str_subseq() to specify C string + position properly to fix require non ascii path. + [ruby-core:53733] [Bug #8165] + + * test/ruby/test_require.rb (TestRequire#test_require_nonascii_path): + a test for the above. + Sun Apr 21 00:13:24 2013 Nobuyoshi Nakada <nobu@ruby-lang.org> * load.c (rb_feature_p), vm_core.h (rb_vm_struct): turn @@ -247,16 +247,16 @@ features_index_add(VALUE feature, VALUE offset) if (p < feature_str) break; /* Now *p == '/'. We reach this point for every '/' in `feature`. */ - short_feature = rb_str_substr(feature, p + 1 - feature_str, feature_end - p - 1); + short_feature = rb_str_subseq(feature, p + 1 - feature_str, feature_end - p - 1); features_index_add_single(short_feature, offset); if (ext) { - short_feature = rb_str_substr(feature, p + 1 - feature_str, ext - p - 1); + short_feature = rb_str_subseq(feature, p + 1 - feature_str, ext - p - 1); features_index_add_single(short_feature, offset); } } features_index_add_single(feature, offset); if (ext) { - short_feature = rb_str_substr(feature, 0, ext - feature_str); + short_feature = rb_str_subseq(feature, 0, ext - feature_str); features_index_add_single(short_feature, offset); } } diff --git a/test/ruby/test_require.rb b/test/ruby/test_require.rb index f6e75a8eaf..c9326380e6 100644 --- a/test/ruby/test_require.rb +++ b/test/ruby/test_require.rb @@ -58,6 +58,29 @@ class TestRequire < Test::Unit::TestCase end end + def test_require_nonascii_path + bug8165 = '[ruby-core:53733] [Bug #8165]' + Dir.mktmpdir {|tmp| + encoding = /mswin|mingw/ =~ RUBY_PLATFORM ? 'filesystem' : 'UTF-8' + dir = "\u3042" * 5 + begin + require_path = File.join(tmp, dir, 'foo.rb').encode(encoding) + rescue + skip "cannot convert path encoding to #{encoding}" + end + Dir.mkdir(File.dirname(require_path)) + open(require_path, "wb") {} + assert_in_out_err([], <<-INPUT, %w(:ok), [], bug8165) + # coding: #{encoding} + # leave paths for require encoding objects + enc_path = Regexp.new(Regexp.escape(RUBY_PLATFORM)) + $:.replace([IO::NULL] + $:.reject {|path| enc_path !~ path}) + p :ok if require '#{require_path}' + p :ng if require '#{require_path}' + INPUT + } + end + def test_require_path_home_1 env_rubypath, env_home = ENV["RUBYPATH"], ENV["HOME"] pathname_too_long = /pathname too long \(ignored\).*\(LoadError\)/m @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.0.0" #define RUBY_RELEASE_DATE "2013-04-21" -#define RUBY_PATCHLEVEL 157 +#define RUBY_PATCHLEVEL 158 #define RUBY_RELEASE_YEAR 2013 #define RUBY_RELEASE_MONTH 4 |
