Skip to content

Commit

Permalink
rb_is_absolute_path() renamed from is_absolute_path()
Browse files Browse the repository at this point in the history
  • Loading branch information
Watson1978 committed Dec 30, 2011
1 parent 2362c3b commit 1a7418b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
17 changes: 9 additions & 8 deletions file.c
Expand Up @@ -2445,8 +2445,6 @@ rb_path_end(const char *path)
return chompdirsep(path);
}

static int is_absolute_path(const char*);

/*
* call-seq:
* File.expand_path(file_name [, dir_string] ) -> abs_file_name
Expand Down Expand Up @@ -4048,10 +4046,13 @@ rb_file_const(const char *name, VALUE value)
rb_define_const(rb_mFConst, name, value);
}

static int
is_absolute_path(const char *path)
int
rb_is_absolute_path(const char *path)
{
return path[0] == '/';
if (path[0] == '/') {
return 1;
}
return 0;
}

#ifndef ENABLE_PATH_CHECK
Expand All @@ -4066,7 +4067,7 @@ path_check_0(VALUE path, int execpath)
const char *p0 = StringValueCStr(path);
char *p = 0, *s;

if (!is_absolute_path(p0)) {
if (!rb_is_absolute_path(p0)) {
VALUE newpath = ruby_getcwd();
rb_str_cat2(newpath, "/");
rb_str_cat2(newpath, p0);
Expand Down Expand Up @@ -4197,7 +4198,7 @@ rb_find_file_ext_safe(VALUE *filep, const char *const *ext, int safe_level)
expanded = 1;
}

if (expanded || is_absolute_path(f) || is_explicit_relative(f)) {
if (expanded || rb_is_absolute_path(f) || is_explicit_relative(f)) {
if (safe_level >= 1 && !fpath_check(fname)) {
rb_raise(rb_eSecurityError, "loading from unsafe path %s", f);
}
Expand Down Expand Up @@ -4267,7 +4268,7 @@ rb_find_file_safe(VALUE path, int safe_level)
expanded = 1;
}

if (expanded || is_absolute_path(f) || is_explicit_relative(f)) {
if (expanded || rb_is_absolute_path(f) || is_explicit_relative(f)) {
if (safe_level >= 1 && !fpath_check(path)) {
rb_raise(rb_eSecurityError, "loading from unsafe path %s", f);
}
Expand Down
1 change: 1 addition & 0 deletions include/ruby/intern.h
Expand Up @@ -282,6 +282,7 @@ VALUE rb_find_file(VALUE);
#define rb_path_skip_prefix(path) (path)
char *rb_path_end(const char *);
VALUE rb_str_encode_ospath(VALUE);
int rb_is_absolute_path(const char *);

/* gc.c */
void ruby_set_stack_size(size_t);
Expand Down

0 comments on commit 1a7418b

Please sign in to comment.