Merge pull request #7735 from MikeMcQuaid/tap-new-restrict-names

tap-new: restrict new tap names.
This commit is contained in:
Mike McQuaid 2020-06-12 12:03:55 +01:00 committed by GitHub
commit ddf20bdc09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -22,7 +22,10 @@ module Homebrew
def tap_new
tap_new_args.parse
tap_name = args.named.first
tap = Tap.fetch(args.named.first)
raise "Invalid tap name '#{tap_name}'" unless tap.path.to_s.match?(HOMEBREW_TAP_PATH_REGEX)
titleized_user = tap.user.dup
titleized_repo = tap.repo.dup
titleized_user[0] = titleized_user[0].upcase

View File

@ -34,10 +34,7 @@ class Tap
return CoreTap.instance if ["Homebrew", "Linuxbrew"].include?(user) && ["core", "homebrew"].include?(repo)
cache_key = "#{user}/#{repo}".downcase
tap = cache.fetch(cache_key) { |key| cache[key] = Tap.new(user, repo) }
raise "Invalid tap name '#{args.join("/")}'" unless tap.path.to_s.match?(HOMEBREW_TAP_PATH_REGEX)
tap
cache.fetch(cache_key) { |key| cache[key] = Tap.new(user, repo) }
end
def self.from_path(path)