1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

merge revision(s) r47591: [Backport #10242]

* ext/pathname/lib/pathname.rb (SAME_PATHS):
	  Pathname#relative_path_from uses String#casecmp to compare strings
	  on case-insensitive filesystem platforms (e.g., Windows). This can
	  return nil for strings with different encodings, and the code
	  previously assumed that it always returned a Fixnum.  [Fix GH-713]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47596 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nagachika 2014-09-15 14:11:00 +00:00
parent eba7b76c4c
commit e54ec54d2d
4 changed files with 24 additions and 2 deletions

View file

@ -1,3 +1,11 @@
Mon Sep 15 22:34:39 2014 Natalie Weizenbaum <nweiz@google.com>
* ext/pathname/lib/pathname.rb (SAME_PATHS):
Pathname#relative_path_from uses String#casecmp to compare strings
on case-insensitive filesystem platforms (e.g., Windows). This can
return nil for strings with different encodings, and the code
previously assumed that it always returned a Fixnum. [Fix GH-713]
Mon Sep 15 22:31:33 2014 Sho Hashimoto <sho.hsmt@gmail.com>
* ext/fiddle/lib/fiddle/import.rb (Fiddle::Importer#sizeof): fix typo,

View file

@ -22,7 +22,8 @@ class Pathname
end
SAME_PATHS = if File::FNM_SYSCASE.nonzero?
proc {|a, b| a.casecmp(b).zero?}
# Avoid #zero? here because #casecmp can return nil.
proc {|a, b| a.casecmp(b) == 0}
else
proc {|a, b| a == b}
end

View file

@ -1322,4 +1322,17 @@ class TestPathname < Test::Unit::TestCase
assert_equal("foo/bar", File.join(Pathname.new("foo"), Pathname.new("bar").taint))
}.call
end
def test_relative_path_from_casefold
assert_separately([], <<-'end;') # do
module File::Constants
remove_const :FNM_SYSCASE
FNM_SYSCASE = FNM_CASEFOLD
end
require 'pathname'
foo = Pathname.new("fo\u{f6}")
bar = Pathname.new("b\u{e4}r".encode("ISO-8859-1"))
assert_instance_of(Pathname, foo.relative_path_from(bar))
end;
end
end

View file

@ -1,6 +1,6 @@
#define RUBY_VERSION "2.1.2"
#define RUBY_RELEASE_DATE "2014-09-15"
#define RUBY_PATCHLEVEL 239
#define RUBY_PATCHLEVEL 240
#define RUBY_RELEASE_YEAR 2014
#define RUBY_RELEASE_MONTH 9