diff --git a/Library/Homebrew/cmd/tap.rb b/Library/Homebrew/cmd/tap.rb index d13921572f..3fb5ca65c4 100644 --- a/Library/Homebrew/cmd/tap.rb +++ b/Library/Homebrew/cmd/tap.rb @@ -123,7 +123,7 @@ module Homebrew case path.to_s when HOMEBREW_TAP_PATH_REGEX "#$1/#$2/#{File.basename($3, '.rb')}" - when %r{^#{HOMEBREW_LIBRARY}/Formula/(.+)} + when %r{^#{Regexp.escape(HOMEBREW_LIBRARY.to_s)}/Formula/(.+)}o "Homebrew/homebrew/#{File.basename($1, '.rb')}" else nil diff --git a/Library/Homebrew/cmd/update.rb b/Library/Homebrew/cmd/update.rb index 7bced13a98..b1ee8d8fef 100644 --- a/Library/Homebrew/cmd/update.rb +++ b/Library/Homebrew/cmd/update.rb @@ -266,7 +266,7 @@ class Report def select_formula key fetch(key, []).map do |path| case path.to_s - when Regexp.new(HOMEBREW_LIBRARY + "/Formula") + when %r{^#{Regexp.escape(HOMEBREW_LIBRARY.to_s)}/Formula}o path.basename(".rb").to_s when HOMEBREW_TAP_PATH_REGEX "#$1/#{$2.sub("homebrew-", "")}/#{path.basename(".rb")}" diff --git a/Library/Homebrew/tap_constants.rb b/Library/Homebrew/tap_constants.rb index d706d85296..3550a06377 100644 --- a/Library/Homebrew/tap_constants.rb +++ b/Library/Homebrew/tap_constants.rb @@ -3,6 +3,6 @@ HOMEBREW_TAP_ARGS_REGEX = %r{^([\w-]+)/(homebrew-)?([\w-]+)$} # match taps' formula, e.g. someuser/sometap/someformula HOMEBREW_TAP_FORMULA_REGEX = %r{^([\w-]+)/([\w-]+)/([\w+-]+)$} # match taps' directory path, e.g. HOMEBREW_LIBRARY/Taps/someuser/sometap -HOMEBREW_TAP_DIR_REGEX = %r{#{HOMEBREW_LIBRARY}/Taps/([\w-]+)/([\w-]+)} +HOMEBREW_TAP_DIR_REGEX = %r{#{Regexp.escape(HOMEBREW_LIBRARY.to_s)}/Taps/([\w-]+)/([\w-]+)} # match taps' formula path, e.g. HOMEBREW_LIBRARY/Taps/someuser/sometap/someformula HOMEBREW_TAP_PATH_REGEX = Regexp.new(HOMEBREW_TAP_DIR_REGEX.source + %r{/(.*)}.source)