mirror of
https://github.com/ruby/ruby.git
synced 2025-09-17 01:23:57 +02:00
merges r28685 from trunk into ruby_1_9_2.
-- * lib/fileutils.rb (FileUtils::Entry_#copy): check file name spearator boundary. [ruby-core:31360] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@28743 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7252a95e73
commit
d1a5bcd83f
3 changed files with 26 additions and 1 deletions
|
@ -1240,7 +1240,7 @@ module FileUtils
|
|||
when file?
|
||||
copy_file dest
|
||||
when directory?
|
||||
if !File.exist?(dest) and /^#{Regexp.quote(path)}/ =~ File.dirname(dest)
|
||||
if !File.exist?(dest) and descendant_diretory?(dest, path)
|
||||
raise ArgumentError, "cannot copy directory %s to itself %s" % [path, dest]
|
||||
end
|
||||
begin
|
||||
|
@ -1394,6 +1394,17 @@ module FileUtils
|
|||
return File.path(base) if not dir or dir == '.'
|
||||
File.join(dir, base)
|
||||
end
|
||||
|
||||
if File::ALT_SEPARATOR
|
||||
DIRECTORY_TERM = "(?=[/#{Regexp.quote(File::ALT_SEPARATOR)}]|\\z)".freeze
|
||||
else
|
||||
DIRECTORY_TERM = "(?=/|\\z)".freeze
|
||||
end
|
||||
SYSCASE = File::FNM_SYSCASE.nonzero? ? "-i" : ""
|
||||
|
||||
def descendant_diretory?(descendant, ascendant)
|
||||
/\A(?#{SYSCASE}:#{Regexp.quote(ascendant)})#{DIRECTORY_TERM}/ =~ File.dirname(descendant)
|
||||
end
|
||||
end # class Entry_
|
||||
|
||||
def fu_list(arg) #:nodoc:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue