diff --git a/lib/cask/artifact/uninstall_base.rb b/lib/cask/artifact/uninstall_base.rb index 8d6e622a3f07..592e3843191f 100644 --- a/lib/cask/artifact/uninstall_base.rb +++ b/lib/cask/artifact/uninstall_base.rb @@ -15,9 +15,9 @@ def self.expand_path_strings(path_strings) end def self.remove_relative_path_strings(action, path_strings) - relative = path_strings.reject do |path_string| - %r{\A/}.match(path_string) - end + relative = path_strings.map do |path_string| + path_string if %r{/\.\.(?:/|\Z)}.match(path_string) or ! %r{\A/}.match(path_string) + end.compact relative.each do |path_string| opoo %Q{Skipping #{action} for relative path #{path_string}} end diff --git a/test/support/Casks/with-installable.rb b/test/support/Casks/with-installable.rb index 324725fb3958..2c1dc9f7f62d 100644 --- a/test/support/Casks/with-installable.rb +++ b/test/support/Casks/with-installable.rb @@ -10,5 +10,6 @@ class WithInstallable < TestCask '/permissible/absolute/path', '~/impermissible/path/with/tilde', 'impermissible/relative/path', + '/another/impermissible/../relative/path', ] end