From c5536e1e08a13352cf241a2c3f7b2aa75a8e31d6 Mon Sep 17 00:00:00 2001 From: Xu Cheng Date: Wed, 9 Sep 2015 13:55:19 +0800 Subject: [PATCH] Descriptions.cache_formulae: secure formulae loading --- Library/Homebrew/descriptions.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/descriptions.rb b/Library/Homebrew/descriptions.rb index e74a840286..5f7f44c4d4 100644 --- a/Library/Homebrew/descriptions.rb +++ b/Library/Homebrew/descriptions.rb @@ -1,4 +1,5 @@ require "formula" +require "formula_versions" require "csv" class Descriptions @@ -92,7 +93,13 @@ class Descriptions # cache. Save the updated cache to disk, unless explicitly told not to. def self.cache_formulae(formula_names, options = { :save => true }) if self.cache - formula_names.each { |name| @cache[name] = Formula[name].desc } + formula_names.each do |name| + begin + desc = Formulary.factory(name).desc + rescue FormulaUnavailableError, *FormulaVersions::IGNORED_EXCEPTIONS + end + @cache[name] = desc + end self.save_cache if options[:save] end end