tap-new: restrict new tap names.

Don't want to restrict this for all taps otherwise existing ones may
explode.

Fixes #7734
This commit is contained in:
Mike McQuaid 2020-06-12 11:42:40 +01:00
parent 91b4d45070
commit f94a38e4b1
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70
2 changed files with 4 additions and 4 deletions

View File

@ -22,7 +22,10 @@ module Homebrew
def tap_new def tap_new
tap_new_args.parse tap_new_args.parse
tap_name = args.named.first
tap = Tap.fetch(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_user = tap.user.dup
titleized_repo = tap.repo.dup titleized_repo = tap.repo.dup
titleized_user[0] = titleized_user[0].upcase 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) return CoreTap.instance if ["Homebrew", "Linuxbrew"].include?(user) && ["core", "homebrew"].include?(repo)
cache_key = "#{user}/#{repo}".downcase cache_key = "#{user}/#{repo}".downcase
tap = cache.fetch(cache_key) { |key| cache[key] = Tap.new(user, repo) } 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
end end
def self.from_path(path) def self.from_path(path)