diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-10-26 06:24:29 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-10-26 06:24:29 +0000 |
commit | cba2e89cdc2e48f865f0a3a68f8d0ebd2ae1d69c (patch) | |
tree | 766ecf87375a4c4f3b676fb1a5c7412988124a89 | |
parent | 49f6242b34f1daf9591b262c48723b7f2e7883d3 (diff) | |
download | ruby-cba2e89cdc2e48f865f0a3a68f8d0ebd2ae1d69c.tar.gz |
* file.c (rb_file_join): honor input encodings than ASCII-8BIT.
[ruby-core:40338] [Bug #5483]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33525 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | file.c | 5 | ||||
-rw-r--r-- | test/ruby/test_path.rb | 9 |
3 files changed, 18 insertions, 1 deletions
@@ -1,3 +1,8 @@ +Wed Oct 26 15:24:25 2011 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * file.c (rb_file_join): honor input encodings than ASCII-8BIT. + [ruby-core:40338] [Bug #5483] + Tue Oct 25 21:52:31 2011 Tanaka Akira <akr@fsij.org> * include/ruby/defines.h: use "__sparc" instead of "sparc" and @@ -3847,7 +3847,10 @@ rb_file_join(VALUE ary, VALUE sep) FilePathStringValue(tmp); } name = StringValueCStr(result); - if (i > 0 && !NIL_P(sep)) { + if (i == 0) { + rb_enc_copy(result, tmp); + } + else if (!NIL_P(sep)) { tail = chompdirsep(name); if (RSTRING_PTR(tmp) && isdirsep(RSTRING_PTR(tmp)[0])) { rb_str_set_len(result, tail - name); diff --git a/test/ruby/test_path.rb b/test/ruby/test_path.rb index 74d568ae49..2db7be0b76 100644 --- a/test/ruby/test_path.rb +++ b/test/ruby/test_path.rb @@ -247,4 +247,13 @@ class TestPath < Test::Unit::TestCase assert_raise(Encoding::CompatibilityError) {open(s.encode("utf-32be"))} assert_raise(Encoding::CompatibilityError) {open(s.encode("utf-32le"))} end + + def test_join + bug5483 = '[ruby-core:40338]' + path = %w[a b] + Encoding.list.each do |e| + next unless e.ascii_compatible? + assert_equal(e, File.join(*path.map {|s| s.force_encoding(e)}).encoding, bug5483) + end + end end |