diff options
author | Jon Morrow <jon@morrowmail.com> | 2015-05-06 17:03:45 -0700 |
---|---|---|
committer | Jon Morrow <jon@morrowmail.com> | 2015-05-06 17:03:45 -0700 |
commit | d3b6b1169978be7cac457a02771b9f417d779c93 (patch) | |
tree | b8d799fad66e09133862eeee0d54831bebe7bb48 /lib/chef/http/basic_client.rb | |
parent | e4bf480137d5e06aba7c9fee4ae1577361a44a47 (diff) | |
download | chef-d3b6b1169978be7cac457a02771b9f417d779c93.tar.gz |
Check if proxy env_var is empty
We need to check if the env variable is set to empty string. If we don't we can get in an edge case where we blow up trying to call URI.parse.
Diffstat (limited to 'lib/chef/http/basic_client.rb')
-rw-r--r-- | lib/chef/http/basic_client.rb | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/chef/http/basic_client.rb b/lib/chef/http/basic_client.rb index 076d152d16..de5e7c03a8 100644 --- a/lib/chef/http/basic_client.rb +++ b/lib/chef/http/basic_client.rb @@ -101,12 +101,16 @@ class Chef env["#{url.scheme.upcase}_PROXY"] || env["#{url.scheme}_proxy"] # Check if the proxy string contains a scheme. If not, add the url's scheme to the - # proxy before parsing. The regex /^.*:\/\// matches, for example, http://. - proxy = if proxy.match(/^.*:\/\//) - URI.parse(proxy) - else - URI.parse("#{url.scheme}://#{proxy}") - end if String === proxy + # proxy before parsing. The regex /^.*:\/\// matches, for example, http://. Reusing proxy + # here since we are really just trying to get the string built correctly. + if String === proxy && !proxy.strip.empty? + if proxy.match(/^.*:\/\//) + proxy = URI.parse(proxy.strip) + else + proxy = URI.parse("#{url.scheme}://#{proxy.strip}") + end + end + no_proxy = Chef::Config[:no_proxy] || env['NO_PROXY'] || env['no_proxy'] excludes = no_proxy.to_s.split(/\s*,\s*/).compact excludes = excludes.map { |exclude| exclude =~ /:\d+$/ ? exclude : "#{exclude}:*" } |