mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
load.c: transcode path
* load.c (rb_f_load): path name needs to be transcoded to OS path encoding. [ruby-list:49994] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48186 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5de3e7e2bd
commit
ef276e959e
3 changed files with 32 additions and 3 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Wed Oct 29 14:44:27 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* load.c (rb_f_load): path name needs to be transcoded to OS path
|
||||||
|
encoding. [ruby-list:49994]
|
||||||
|
|
||||||
Wed Oct 29 11:48:23 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Wed Oct 29 11:48:23 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* configure.in (__builtin_setjmp): disable with gcc/clang earlier
|
* configure.in (__builtin_setjmp): disable with gcc/clang earlier
|
||||||
|
|
8
load.c
8
load.c
|
@ -683,7 +683,7 @@ rb_load_protect(VALUE fname, int wrap, int *state)
|
||||||
static VALUE
|
static VALUE
|
||||||
rb_f_load(int argc, VALUE *argv)
|
rb_f_load(int argc, VALUE *argv)
|
||||||
{
|
{
|
||||||
VALUE fname, wrap, path;
|
VALUE fname, wrap, path, orig_fname;
|
||||||
|
|
||||||
rb_scan_args(argc, argv, "11", &fname, &wrap);
|
rb_scan_args(argc, argv, "11", &fname, &wrap);
|
||||||
|
|
||||||
|
@ -693,10 +693,12 @@ rb_f_load(int argc, VALUE *argv)
|
||||||
rb_sourceline());
|
rb_sourceline());
|
||||||
}
|
}
|
||||||
|
|
||||||
path = rb_find_file(FilePathValue(fname));
|
orig_fname = FilePathValue(fname);
|
||||||
|
fname = rb_str_encode_ospath(orig_fname);
|
||||||
|
path = rb_find_file(fname);
|
||||||
if (!path) {
|
if (!path) {
|
||||||
if (!rb_file_load_ok(RSTRING_PTR(fname)))
|
if (!rb_file_load_ok(RSTRING_PTR(fname)))
|
||||||
load_failed(fname);
|
load_failed(orig_fname);
|
||||||
path = fname;
|
path = fname;
|
||||||
}
|
}
|
||||||
rb_load_internal(path, RTEST(wrap));
|
rb_load_internal(path, RTEST(wrap));
|
||||||
|
|
|
@ -308,6 +308,28 @@ class TestRequire < Test::Unit::TestCase
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_load_ospath
|
||||||
|
bug = '[ruby-list:49994] path in ospath'
|
||||||
|
base = "test_load\u{3042 3044 3046 3048 304a}".encode(Encoding::Windows_31J)
|
||||||
|
path = nil
|
||||||
|
Tempfile.create([base, ".rb"]) do |t|
|
||||||
|
path = t.path
|
||||||
|
|
||||||
|
assert_raise_with_message(LoadError, /#{base}/) {
|
||||||
|
load(File.join(File.dirname(path), base))
|
||||||
|
}
|
||||||
|
|
||||||
|
t.puts "warn 'ok'"
|
||||||
|
t.close
|
||||||
|
assert_include(path, base)
|
||||||
|
assert_warn("ok\n", bug) {
|
||||||
|
assert_nothing_raised(LoadError, bug) {
|
||||||
|
load(path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_tainted_loadpath
|
def test_tainted_loadpath
|
||||||
Tempfile.create(["test_ruby_test_require", ".rb"]) {|t|
|
Tempfile.create(["test_ruby_test_require", ".rb"]) {|t|
|
||||||
abs_dir, file = File.split(t.path)
|
abs_dir, file = File.split(t.path)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue