install_location(filename, destination_dir)
public
Returns the full path for installing filename.
If filename is not inside destination_dir an exception is
raised.
# File lib/rubygems/package.rb, line 414
def install_location filename, destination_dir # :nodoc:
raise Gem::Package::PathError.new(filename, destination_dir) if
filename.start_with? '/'
destination_dir = realpath destination_dir
destination_dir = File.expand_path destination_dir
destination = File.join destination_dir, filename
destination = File.expand_path destination
raise Gem::Package::PathError.new(destination, destination_dir) unless
destination.start_with? destination_dir + '/'
begin
real_destination = File.expand_path(File.realpath(destination))
rescue
# it's fine if the destination doesn't exist, because rm -rf'ing it can't cause any damage
nil
else
raise Gem::Package::PathError.new(real_destination, destination_dir) unless
real_destination.start_with? destination_dir + '/'
end
destination.untaint
destination
end