Merge pull request #18631 from Homebrew/sf-fixes

rubocops/shared/url_helper: tweak SourceForge handling
This commit is contained in:
Bo Anderson 2024-10-24 20:54:59 +01:00 committed by GitHub
commit 5538282b48
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -97,7 +97,8 @@ module RuboCop
%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 @@ module RuboCop
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 @@ module RuboCop
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