From 3292dc3543e593353a44a2f2250a905d0744ab1e Mon Sep 17 00:00:00 2001 From: Bo Anderson Date: Thu, 24 Oct 2024 20:36:38 +0100 Subject: [PATCH] rubocops/shared/url_helper: tweak SourceForge handling --- Library/Homebrew/rubocops/shared/url_helper.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/rubocops/shared/url_helper.rb b/Library/Homebrew/rubocops/shared/url_helper.rb index b5bad2dfe6f35..1d5e6a32ff943 100644 --- a/Library/Homebrew/rubocops/shared/url_helper.rb +++ b/Library/Homebrew/rubocops/shared/url_helper.rb @@ -97,7 +97,8 @@ def audit_url(type, urls, mirrors, livecheck_url: false) %r{^http://hackage\.haskell\.org/}, %r{^http://(?:[^/]*\.)?archive\.org}, %r{^http://(?:[^/]*\.)?freedesktop\.org}, - %r{^http://(?:[^/]*\.)?mirrorservice\.org/}]) + %r{^http://(?:[^/]*\.)?mirrorservice\.org/}, + %r{^http://downloads?\.sourceforge\.net/}]) audit_urls(urls, http_to_https_patterns) do |_, url, index| # It's fine to have a plain HTTP mirror further down the mirror list. https_url = url.dup.insert(4, "s") @@ -153,7 +154,7 @@ def audit_url(type, urls, mirrors, livecheck_url: false) problem "Don't use /download in SourceForge urls (url is #{url})." if url.end_with?("/download") - if url.match?(%r{^https?://sourceforge\.}) && url != livecheck_url + if url.match?(%r{^https?://(sourceforge|sf)\.}) && url != livecheck_url problem "Use https://downloads.sourceforge.net to get geolocation (url is #{url})." end @@ -165,7 +166,10 @@ def audit_url(type, urls, mirrors, livecheck_url: false) problem "Don't use specific dl mirrors in SourceForge urls (url is #{url})." end - problem "Please use https:// for #{url}" if url.start_with? "http://downloads" + # sf.net does HTTPS -> HTTP redirects. + if url.match?(%r{^https?://downloads?\.sf\.net}) + problem "Use https://downloads.sourceforge.net instead of downloads.sf.net (url is #{url})" + end end # Debian has an abundance of secure mirrors. Let's not pluck the insecure