ruby-changes:25155
From: nobu <ko1@a...>
Date: Tue, 16 Oct 2012 10:54:20 +0900 (JST)
Subject: [ruby-changes:25155] nobu:r37207 (trunk): file.c: ASCII-compatible
nobu 2012-10-16 10:54:05 +0900 (Tue, 16 Oct 2012) New Revision: 37207 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=37207 Log: file.c: ASCII-compatible * file.c (rb_file_join): path names must be ASCII-compatible. [ruby-core:48012] [Bug #7168] Modified files: trunk/ChangeLog trunk/file.c trunk/test/ruby/test_file_exhaustive.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 37206) +++ ChangeLog (revision 37207) @@ -1,5 +1,8 @@ -Tue Oct 16 10:53:29 2012 Nobuyoshi Nakada <nobu@r...> +Tue Oct 16 10:54:03 2012 Nobuyoshi Nakada <nobu@r...> + * file.c (rb_file_join): path names must be ASCII-compatible. + [ruby-core:48012] [Bug #7168] + * file.c (check_path_encoding): new function to ensure path name encoding to be ASCII-compatible. Index: test/ruby/test_file_exhaustive.rb =================================================================== --- test/ruby/test_file_exhaustive.rb (revision 37206) +++ test/ruby/test_file_exhaustive.rb (revision 37207) @@ -772,10 +772,14 @@ s = "foo" + File::SEPARATOR + "bar" + File::SEPARATOR + "baz" assert_equal(s, File.join("foo", "bar", "baz")) assert_equal(s, File.join(["foo", "bar", "baz"])) + o = Object.new def o.to_path; "foo"; end assert_equal(s, File.join(o, "bar", "baz")) assert_equal(s, File.join("foo" + File::SEPARATOR, "bar", File::SEPARATOR + "baz")) + end + + def test_join_alt_separator if File::ALT_SEPARATOR == '\\' a = "\225\\" b = "foo" @@ -785,6 +789,12 @@ end end + def test_join_ascii_incompatible + bug7168 = '[ruby-core:48012]' + names = %w"a b".map {|s| s.encode(Encoding::UTF_16LE)} + assert_raise(Encoding::CompatibilityError, bug7168) {File.join(*names)} + end + def test_truncate assert_equal(0, File.truncate(@file, 1)) file_assertion.exist?(@file) Index: file.c =================================================================== --- file.c (revision 37206) +++ file.c (revision 37207) @@ -3924,6 +3924,7 @@ for (i=0; i<RARRAY_LEN(ary); i++) { tmp = RARRAY_PTR(ary)[i]; if (RB_TYPE_P(tmp, T_STRING)) { + check_path_encoding(tmp); len += RSTRING_LEN(tmp); } else { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/