ruby-changes:25160
From: nobu <ko1@a...>
Date: Tue, 16 Oct 2012 11:27:21 +0900 (JST)
Subject: [ruby-changes:25160] nobu:r37212 (trunk): file.c: ASCII-compatible
nobu 2012-10-16 11:27:07 +0900 (Tue, 16 Oct 2012) New Revision: 37212 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=37212 Log: file.c: ASCII-compatible * file.c (rb_file_join): check nul-byte only for strings, since FilePathStringValue() does it. [ruby-core:48012] [Bug #7168] Modified files: trunk/ChangeLog trunk/file.c trunk/test/ruby/test_file_exhaustive.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 37211) +++ ChangeLog (revision 37212) @@ -1,5 +1,8 @@ -Tue Oct 16 10:54:03 2012 Nobuyoshi Nakada <nobu@r...> +Tue Oct 16 11:27:04 2012 Nobuyoshi Nakada <nobu@r...> + * file.c (rb_file_join): check nul-byte only for strings, since + FilePathStringValue() does it. [ruby-core:48012] [Bug #7168] + * file.c (rb_file_join): path names must be ASCII-compatible. [ruby-core:48012] [Bug #7168] Index: test/ruby/test_file_exhaustive.rb =================================================================== --- test/ruby/test_file_exhaustive.rb (revision 37211) +++ test/ruby/test_file_exhaustive.rb (revision 37212) @@ -793,6 +793,18 @@ bug7168 = '[ruby-core:48012]' names = %w"a b".map {|s| s.encode(Encoding::UTF_16LE)} assert_raise(Encoding::CompatibilityError, bug7168) {File.join(*names)} + assert_raise(Encoding::CompatibilityError, bug7168) {File.join(names)} + + a = Object.new + b = names[1] + names = [a, "b"] + a.singleton_class.class_eval do + define_method(:to_path) do + names[1] = b + "a" + end + end + assert_raise(Encoding::CompatibilityError, bug7168) {File.join(names)} end def test_truncate Index: file.c =================================================================== --- file.c (revision 37211) +++ file.c (revision 37212) @@ -3941,6 +3941,7 @@ tmp = RARRAY_PTR(ary)[i]; switch (TYPE(tmp)) { case T_STRING: + StringValueCStr(tmp); break; case T_ARRAY: if (ary == tmp) { @@ -3957,8 +3958,7 @@ default: FilePathStringValue(tmp); } - name = StringValueCStr(result); - len = RSTRING_LEN(result); + RSTRING_GETMEM(result, name, len); if (i == 0) { rb_enc_copy(result, tmp); } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/