Merge pull request #19621 from abitrolly/create-url-not-file

create: check that downloaded URL is actually archive
This commit is contained in:
Mike McQuaid 2025-03-28 08:52:00 +00:00 committed by GitHub
commit 7b2ca65eac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -82,7 +82,13 @@ module Homebrew
r = Resource.new
r.url(@url)
r.owner = self
@sha256 = r.fetch.sha256 if r.download_strategy == CurlDownloadStrategy
filepath = r.fetch
html_doctype_prefix = "<!doctype html"
if File.read(filepath, html_doctype_prefix.length).downcase.start_with?(html_doctype_prefix)
raise "Downloaded URL is not archive"
end
@sha256 = filepath.sha256
end
if @github