update: secure formula loading in rename

For update, all formula loading need to be secured by `rescue`.
Otherwise it's easy to crash `brew update` for vasty reasons, e.g.
new Formula DSL.

Closes Homebrew/homebrew#43353.

Signed-off-by: Xu Cheng <xucheng@me.com>
This commit is contained in:
Xu Cheng 2015-08-28 15:59:53 +08:00
parent 9520449823
commit 3458b99d6e

View File

@ -78,7 +78,14 @@ module Homebrew
next unless (dir = HOMEBREW_CELLAR/oldname).directory? && !dir.subdirs.empty?
begin
migrator = Migrator.new(Formulary.factory("#{user}/#{repo}/#{newname}"))
f = Formulary.factory("#{user}/#{repo}/#{newname}")
rescue FormulaUnavailableError, *FormulaVersions::IGNORED_EXCEPTIONS
end
next unless f
begin
migrator = Migrator.new(f)
migrator.migrate
rescue Migrator::MigratorDifferentTapsError
end