Skip to content

Commit bdbd806

Browse files
authored
Merge pull request #20026 from abitrolly/non-archive-fix
create: fix archive check if HTML starts with spaces
2 parents 8c6b3db + e71b147 commit bdbd806

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Library/Homebrew/formula_creator.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,10 @@ def write_formula!
8484
r.owner = self
8585
filepath = r.fetch
8686
html_doctype_prefix = "<!doctype html"
87-
if File.read(filepath, html_doctype_prefix.length).downcase.start_with?(html_doctype_prefix)
87+
# Number of bytes to read from file start to ensure it is not HTML.
88+
# HTML may start with arbitrary number of whitespace lines.
89+
bytes_to_read = 100
90+
if File.read(filepath, bytes_to_read).strip.downcase.start_with?(html_doctype_prefix)
8891
raise "Downloaded URL is not archive"
8992
end
9093

0 commit comments

Comments
 (0)