Skip to content

Commit

Permalink
Merge pull request #66 from jeremyevans/always-allow-env-18908
Browse files Browse the repository at this point in the history
Remove ENVIRONMENT_VARIABLE_IS_MULTIUSER_SAFE
  • Loading branch information
hsbt authored Sep 28, 2022
2 parents 196f3d7 + 1e45851 commit 3b8471d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 23 deletions.
11 changes: 2 additions & 9 deletions lib/net/http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1221,16 +1221,9 @@ def proxy_port
end
end

# [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
if ENVIRONMENT_VARIABLE_IS_MULTIUSER_SAFE && @proxy_from_env
if @proxy_from_env
user = proxy_uri&.user
unescape(user) if user
else
Expand All @@ -1240,7 +1233,7 @@ def proxy_user

# The password of the proxy server, if one is configured.
def proxy_pass
if ENVIRONMENT_VARIABLE_IS_MULTIUSER_SAFE && @proxy_from_env
if @proxy_from_env
pass = proxy_uri&.password
unescape(pass) if pass
else
Expand Down
18 changes: 4 additions & 14 deletions test/net/http/test_http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,8 @@ def test_proxy_eh_ENV_with_user
http = Net::HTTP.new 'hostname.example'

assert_equal true, http.proxy?
if Net::HTTP::ENVIRONMENT_VARIABLE_IS_MULTIUSER_SAFE
assert_equal 'foo', http.proxy_user
assert_equal 'bar', http.proxy_pass
else
assert_nil http.proxy_user
assert_nil http.proxy_pass
end
assert_equal 'foo', http.proxy_user
assert_equal 'bar', http.proxy_pass
end
end

Expand All @@ -195,13 +190,8 @@ def test_proxy_eh_ENV_with_urlencoded_user
http = Net::HTTP.new 'hostname.example'

assert_equal true, http.proxy?
if Net::HTTP::ENVIRONMENT_VARIABLE_IS_MULTIUSER_SAFE
assert_equal "Y\\X", http.proxy_user
assert_equal "R%S] ?X", http.proxy_pass
else
assert_nil http.proxy_user
assert_nil http.proxy_pass
end
assert_equal "Y\\X", http.proxy_user
assert_equal "R%S] ?X", http.proxy_pass
end
end

Expand Down

0 comments on commit 3b8471d

Please sign in to comment.