Expand from root rather than current working directory

This commit is contained in:
John Lees-Miller 2018-08-26 19:55:26 +01:00
parent 3dd165b494
commit 8a1de58286
1 changed files with 3 additions and 2 deletions

View File

@ -115,8 +115,9 @@ module Zip
def name_safe? def name_safe?
cleanpath = Pathname.new(@name).cleanpath cleanpath = Pathname.new(@name).cleanpath
return false unless cleanpath.relative? return false unless cleanpath.relative?
naive_expanded_path = ::File.join(Dir.pwd, cleanpath.to_s) root = ::File::SEPARATOR
cleanpath.expand_path.to_s == naive_expanded_path naive_expanded_path = ::File.join(root, cleanpath.to_s)
cleanpath.expand_path(root).to_s == naive_expanded_path
end end
def local_entry_offset #:nodoc:all def local_entry_offset #:nodoc:all