More styling fixes

This commit is contained in:
L. E. Segovia 2018-11-24 11:21:52 +00:00
parent 62fd4a2e00
commit 3b79b4d079
No known key found for this signature in database
GPG Key ID: D5D1DC48B52B7AD5
2 changed files with 9 additions and 8 deletions

View File

@ -322,7 +322,7 @@ module Cask
def check_https_availability
return unless download
unless cask.url.blank? || cask.url.using
if !cask.url.blank? && !cask.url.using
check_url_for_https_availability(cask.url, user_agents: [cask.url.user_agent])
end
check_url_for_https_availability(cask.appcast) unless cask.appcast.blank?
@ -331,7 +331,7 @@ module Cask
def check_url_for_https_availability(url_to_check, user_agents: [:default])
problem = curl_check_http_content(url_to_check.to_s, user_agents: user_agents)
add_error problem unless problem.nil?
add_error problem if problem
end
end
end

View File

@ -116,8 +116,9 @@ def curl_check_http_content(url, user_agents: [:default], check_content: false,
file_match = details[:file_hash] == secure_details[:file_hash]
if (etag_match || content_length_match || file_match) &&
secure_details[:final_url].start_with?("https://")
return "The URL #{url} should use HTTPS rather than HTTP" if url.start_with?("http://")
secure_details[:final_url].start_with?("https://") &&
url.start_with?("http://")
return "The URL #{url} should use HTTPS rather than HTTP"
end
return unless check_content
@ -128,8 +129,9 @@ def curl_check_http_content(url, user_agents: [:default], check_content: false,
# Check for the same content after removing all protocols
if (details[:file] == secure_details[:file]) &&
secure_details[:final_url].start_with?("https://")
return "The URL #{url} should use HTTPS rather than HTTP" if url.start_with?("http://")
secure_details[:final_url].start_with?("https://") &&
url.start_with?("http://")
return "The URL #{url} should use HTTPS rather than HTTP"
end
return unless strict
@ -157,8 +159,7 @@ def curl_http_content_headers_and_checksum(url, hash_needed: false, user_agent:
while status_code == :unknown || status_code.to_s.start_with?("3")
headers, _, output = output.partition("\r\n\r\n")
status_code = headers[%r{HTTP\/.* (\d+)}, 1]
location = headers[/^Location:\s*(.*)$/i, 1]
final_url = location.chomp if location
final_url = headers[/^Location:\s*(.*)$/i, 1]&.chomp
end
output_hash = Digest::SHA256.digest(output) if hash_needed