summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-09-18 07:06:29 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-09-18 07:06:29 +0000
commit6200f424a721981d739410ea3937990e3831bc7d (patch)
tree20dfc8bba1ab37661f31cb7c340256fc70638042
parentf2b68df43ef25133dcc954a802a9b41ad2897552 (diff)
* dir.c (GlobPathValue): glob allows null bytes as separators.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24998 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--dir.c12
2 files changed, 13 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 65dafbfb640..2db469c1f22 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Fri Sep 18 16:06:27 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * dir.c (GlobPathValue): glob allows null bytes as separators.
+
Fri Sep 18 10:11:53 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* doc/re.rdoc: use rdoc mode.
diff --git a/dir.c b/dir.c
index e9f9d6116ab..55c1608c5e1 100644
--- a/dir.c
+++ b/dir.c
@@ -339,6 +339,12 @@ static const rb_data_type_t dir_data_type = {
static VALUE dir_close(VALUE);
+#define GlobPathValue(str, safe) \
+ /* can contain null bytes as separators */ \
+ (!RB_TYPE_P(str, T_STRING) ? \
+ FilePathValue(str) : \
+ (safe) ? rb_check_safe_obj(str) : (str))
+
static VALUE
dir_s_alloc(VALUE klass)
{
@@ -385,7 +391,7 @@ dir_initialize(int argc, VALUE *argv, VALUE dir)
}
}
- FilePathValue(dirname);
+ GlobPathValue(dirname, FALSE);
TypedData_Get_Struct(dir, struct dir_data, &dir_data_type, dp);
if (dp->dir) closedir(dp->dir);
@@ -1623,7 +1629,7 @@ rb_push_glob(VALUE str, int flags) /* '\0' is delimiter */
long offset = 0;
VALUE ary;
- FilePathValue(str);
+ GlobPathValue(str, TRUE);
ary = rb_ary_new();
while (offset < RSTRING_LEN(str)) {
@@ -1653,7 +1659,7 @@ dir_globs(long argc, VALUE *argv, int flags)
for (i = 0; i < argc; ++i) {
int status;
VALUE str = argv[i];
- FilePathValue(str);
+ GlobPathValue(str, TRUE);
status = push_glob(ary, str, flags);
if (status) GLOB_JUMP_TAG(status);
}