From c7ec1b1f599de0297bbf2cba92a923a337df73a6 Mon Sep 17 00:00:00 2001 From: naruse Date: Sun, 23 Apr 2017 16:19:23 +0000 Subject: Allow Net::HTTP to fetch user/pass from http_proxy Note that this feature is enabled only on environment variables are multi-user safe. In this time the list includes Linux, FreeBSD, or Darwin. [Bug #12921] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58461 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/net/http.rb | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'lib/net/http.rb') diff --git a/lib/net/http.rb b/lib/net/http.rb index 5a22fc0015..c648f0acc4 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -1080,14 +1080,29 @@ module Net #:nodoc: end end - # The proxy username, if one is configured + # [Bug #12921] + if /linux|freebsd|darwin/ =~ RUBY_PLATFORM + ENVIRONMENT_VARIABLE_IS_MULTIUSER_SAFE = true + else + ENVIRONMENT_VARIABLE_IS_MULTIUSER_SAFE = false + end + + # The username of the proxy server, if one is configured. def proxy_user - @proxy_user + if ENVIRONMENT_VARIABLE_IS_MULTIUSER_SAFE && @proxy_from_env + proxy_uri&.user + else + @proxy_user + end end - # The proxy password, if one is configured + # The password of the proxy server, if one is configured. def proxy_pass - @proxy_pass + if ENVIRONMENT_VARIABLE_IS_MULTIUSER_SAFE && @proxy_from_env + proxy_uri&.password + else + @proxy_pass + end end alias proxyaddr proxy_address #:nodoc: obsolete -- cgit v1.2.3