From ef6d01fc8f8a10e1ab10645cc880be2c57ee44da Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Thu, 7 Feb 2013 12:43:22 -0600 Subject: [PATCH] download_strategy: move requires out of method This can cause subtle issues when an exception is marshaled between the build process and the main Homebrew process, as the marshaled exception may contain URI objects even when the main Homebrew process has not loaded the URI library. Closes Homebrew/homebrew#17642. --- Library/Homebrew/download_strategy.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index faa1b96db5..af3e089ad0 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -1,3 +1,6 @@ +require 'open-uri' +require 'vendor/multi_json' + class AbstractDownloadStrategy def initialize name, package @url = package.url @@ -153,9 +156,6 @@ end # Detect and download from Apache Mirror class CurlApacheMirrorDownloadStrategy < CurlDownloadStrategy def _fetch - require 'open-uri' - require 'vendor/multi_json' - mirrors = MultiJson.decode(open("#{@url}&asjson=1").read) url = mirrors.fetch('preferred') + mirrors.fetch('path_info')