tap: more thoroughly validate tap names

`Tap.fetch` and commands building on top of it accepted tap names like
`homebrew/homebrew/bogus` causing some misbehavior. Ensure neither
`user` nor `repo` include slashes and print a more helpful error message
that additionally includes the problematic tap name.

Closes #585.

Closes #591.

Signed-off-by: Martin Afanasjew <martin@afanasjew.de>
This commit is contained in:
Martin Afanasjew 2016-07-27 02:53:41 +02:00
parent 54d1e99ffe
commit d4b5b2080d

View File

@ -25,7 +25,9 @@ class Tap
repo = args[1]
end
raise "Invalid tap name" unless user && repo
if [user, repo].any? { |part| part.nil? || part.include?("/") }
raise "Invalid tap name '#{args.join("/")}'"
end
# we special case homebrew so users don't have to shift in a terminal
user = "Homebrew" if user == "homebrew"