Skip to content

Commit

Permalink
protect against servers lacking content-type
Browse files Browse the repository at this point in the history
  • Loading branch information
gjtorikian committed Jan 20, 2023
1 parent 898c35c commit d0809a7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/html_proofer/url_validator/external.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,12 @@ def check_hash_in_2xx_response(href, url, response, filenames)
return false unless url.hash?

hash = url.hash
headers = response.options.fetch(:headers, {})
content_type = headers.find { |k, _| k.casecmp("content-type").zero? }

# attempt to verify PDF hash ref; see #787 for more details
# FIXME: this is re-reading the PDF response
if /pdf/.match?(response.options[:headers]["content-type"])
if content_type && /pdf/.match?(content_type[1])
io = URI.parse(url.to_s).open
reader = PDF::Reader.new(io)

Expand Down

0 comments on commit d0809a7

Please sign in to comment.