Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

utils/tar: fix validation for tar without directory or extensions #11474

Merged
merged 1 commit into from Jun 2, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions Library/Homebrew/utils/tar.rb
@@ -1,6 +1,8 @@
# typed: true
# frozen_string_literal: true

require "system_command"

module Utils
# Helper functions for interacting with tar files.
#
Expand All @@ -26,9 +28,9 @@ def validate_file(path)

path = Pathname.new(path)
return unless TAR_FILE_EXTENSIONS.include? path.extname
return if Utils.popen_read(executable, "--list", "--file", path).match?(%r{/.*\.})

odie "#{path} is not a valid tar file!"
stdout, _, status = system_command(executable, args: ["--list", "--file", path], print_stderr: false)
odie "#{path} is not a valid tar file!" if !status.success? || stdout.blank?
end

def clear_executable_cache
Expand Down