rubocops/urls: In regexps, only allow valid hostname characters

> This regular expression has an unrestricted wildcard '.*' which may cause 'googlecode\.com/files' to be matched anywhere in the URL, outside the hostname.
This commit is contained in:
Issy Long 2022-04-15 16:36:58 +01:00
parent aa36b343ca
commit f8d9a5c2db
No known key found for this signature in database
GPG Key ID: 8247C390DADC67D4

View File

@ -177,7 +177,7 @@ module RuboCop
end
# Check for new-url Google Code download URLs, https:// is preferred
google_code_pattern = Regexp.union([%r{^http://.*\.googlecode\.com/files.*},
google_code_pattern = Regexp.union([%r{^http://[A-Za-z0-9\-.]*\.googlecode\.com/files.*},
%r{^http://code\.google\.com/}])
audit_urls(urls, google_code_pattern) do |_, url|
problem "Please use https:// for #{url}"