Skip to content

Commit 87e5736

Browse files
committed
create: explain file header length logic
1 parent d860fa1 commit 87e5736

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, 100).strip.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+
head_len = 100
90+
if File.read(filepath, head_len).strip.downcase.start_with?(html_doctype_prefix)
8891
raise "Downloaded URL is not archive"
8992
end
9093

0 commit comments

Comments
 (0)