summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--dir.c5
-rw-r--r--test/ruby/test_dir_m17n.rb10
3 files changed, 19 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 417a001dd1..d667367790 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Sun Oct 4 10:09:57 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * dir.c (rb_dir_getwd): normalize OS path to UTF-8 on OS X.
+
Sun Oct 4 00:09:45 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
* template/ruby-runner.c.in: wrapper to set dynamic loading path
diff --git a/dir.c b/dir.c
index 261f66617d..d3f6530663 100644
--- a/dir.c
+++ b/dir.c
@@ -1012,7 +1012,12 @@ rb_dir_getwd(void)
VALUE cwd;
path = my_getcwd();
+#ifdef __APPLE__
+ cwd = rb_str_normalize_ospath(path, strlen(path));
+ OBJ_TAINT(cwd);
+#else
cwd = rb_tainted_str_new2(path);
+#endif
rb_enc_associate(cwd, rb_filesystem_encoding());
xfree(path);
diff --git a/test/ruby/test_dir_m17n.rb b/test/ruby/test_dir_m17n.rb
index f8fc1ef5e4..1d051143ae 100644
--- a/test/ruby/test_dir_m17n.rb
+++ b/test/ruby/test_dir_m17n.rb
@@ -395,4 +395,14 @@ class TestDir_M17N < Test::Unit::TestCase
pp.assert_equal(orig, ents, bug7267)
}
end
+
+ def test_pwd
+ with_tmpdir {|d|
+ orig = %W"d\u{e9}tente x\u{304c 304e 3050 3052 3054}"
+ orig.each do |n|
+ Dir.mkdir(n)
+ assert_equal(n, File.basename(Dir.chdir(n) {Dir.pwd}))
+ end
+ }
+ end
end