1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

load.c: convert by rb_get_path_check

* load.c (rb_require_internal): convert to path name with the
  given safe level, without setting global safe level.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58987 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2017-06-01 13:05:54 +00:00
parent 31e6dfee6c
commit b9f5cab23a
3 changed files with 6 additions and 5 deletions

2
file.c
View file

@ -200,7 +200,7 @@ rb_get_path_check_convert(VALUE obj, VALUE tmp, int level)
return rb_str_new4(tmp);
}
static VALUE
VALUE
rb_get_path_check(VALUE obj, int level)
{
VALUE tmp = rb_get_path_check_to_string(obj, level);

View file

@ -1168,6 +1168,7 @@ VALUE rb_file_expand_path_fast(VALUE, VALUE);
VALUE rb_file_expand_path_internal(VALUE, VALUE, int, int, VALUE);
VALUE rb_get_path_check_to_string(VALUE, int);
VALUE rb_get_path_check_convert(VALUE, VALUE, int);
VALUE rb_get_path_check(VALUE, int);
void Init_File(void);
int ruby_is_fd_loadable(int fd);

8
load.c
View file

@ -969,6 +969,8 @@ rb_require_internal(VALUE fname, int safe)
RUBY_DTRACE_HOOK(REQUIRE_ENTRY, StringValuePtr(fname));
fname = rb_get_path_check(fname, safe);
TH_PUSH_TAG(th);
saved.safe = rb_safe_level();
if ((state = EXEC_TAG()) == 0) {
@ -976,16 +978,13 @@ rb_require_internal(VALUE fname, int safe)
long handle;
int found;
rb_set_safe_level_force(safe);
FilePathValue(fname);
rb_set_safe_level_force(0);
RUBY_DTRACE_HOOK(FIND_REQUIRE_ENTRY, StringValuePtr(fname));
path = rb_str_encode_ospath(fname);
found = search_required(path, &path, safe);
RUBY_DTRACE_HOOK(FIND_REQUIRE_RETURN, StringValuePtr(fname));
if (found) {
if (!path || !(ftptr = load_lock(RSTRING_PTR(path)))) {
result = 0;
@ -1018,6 +1017,7 @@ rb_require_internal(VALUE fname, int safe)
rb_set_safe_level_force(saved.safe);
if (state) {
RB_GC_GUARD(fname);
/* never TAG_RETURN */
return state;
}