aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-04-23 16:19:23 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-04-23 16:19:23 +0000
commitff59c7586dd4d7be0f161c63d7a57a89f026dc53 (patch)
tree6b5853c6131e7000230a7cc915f3b7cacb6cb3f6 /lib
parent7e72bce2fcf151b8b878c532f3bbe7a363f77539 (diff)
downloadruby-ff59c7586dd4d7be0f161c63d7a57a89f026dc53.tar.gz
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
Diffstat (limited to 'lib')
-rw-r--r--lib/net/http.rb23
1 files changed, 19 insertions, 4 deletions
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