From 8a1de5828658bfa0350c2325f311bd6acad261a2 Mon Sep 17 00:00:00 2001 From: John Lees-Miller Date: Sun, 26 Aug 2018 19:55:26 +0100 Subject: [PATCH] Expand from root rather than current working directory --- lib/zip/entry.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/zip/entry.rb b/lib/zip/entry.rb index 34317d4..fddab51 100644 --- a/lib/zip/entry.rb +++ b/lib/zip/entry.rb @@ -115,8 +115,9 @@ module Zip def name_safe? cleanpath = Pathname.new(@name).cleanpath return false unless cleanpath.relative? - naive_expanded_path = ::File.join(Dir.pwd, cleanpath.to_s) - cleanpath.expand_path.to_s == naive_expanded_path + root = ::File::SEPARATOR + naive_expanded_path = ::File.join(root, cleanpath.to_s) + cleanpath.expand_path(root).to_s == naive_expanded_path end def local_entry_offset #:nodoc:all