Check for empty string when configuring proxies

On some Linux system like debian, the `HTTP_PROXY` are set to an empty
string and was causing the plugin manager to raise an exception. We now
strip the string and check if it is empty before trying to configure the
proxies.

Fixes: #7045

Fixes #7065
This commit is contained in:
Pier-Hugues Pellerin 2017-05-10 09:50:44 -04:00
parent 943147a2f8
commit 17c2f37b25
2 changed files with 21 additions and 2 deletions

View file

@ -56,14 +56,16 @@ end
def configure_proxy
proxies = []
if proxy = (ENV["http_proxy"] || ENV["HTTP_PROXY"])
proxy = (ENV["http_proxy"] || ENV["HTTP_PROXY"])
if !proxy.nil? && !proxy.strip.empty?
proxy_settings = extract_proxy_values_from_uri(proxy)
proxy_settings[:protocol] = "http"
apply_env_proxy_settings(proxy_settings)
proxies << proxy_settings
end
if proxy = (ENV["https_proxy"] || ENV["HTTPS_PROXY"])
proxy = (ENV["https_proxy"] || ENV["HTTPS_PROXY"])
if !proxy.nil? && !proxy.strip.empty?
proxy_settings = extract_proxy_values_from_uri(proxy)
proxy_settings[:protocol] = "https"
apply_env_proxy_settings(proxy_settings)

View file

@ -112,4 +112,21 @@ describe "Proxy support" do
}
end
end
context "when proxies are set with an empty string" do
let(:environments) {
{
"http_proxy" => "",
"https_proxy" => ""
}
}
before do
environments.each { |key, value| ENV[key] = value }
end
it "doesn't raise an exception" do
expect { configure_proxy }.not_to raise_exception
end
end
end