summaryrefslogtreecommitdiff
path: root/lib/rubygems/remote_fetcher.rb
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-08-18 12:56:58 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-08-18 12:56:58 +0000
commit9ce1bf8f3da8a37cea7112b3cb5859da80343b0b (patch)
tree1fb9007e5bb58df9b675dcad67a5169006f95f88 /lib/rubygems/remote_fetcher.rb
parent911ade36df679fbc816456d5d58b5fc8fb1e0db4 (diff)
merge revision(s) 50829: [Backport #11248]
* lib/rubygems.rb: bump version to 2.4.5.1. this version fixed CVE-2015-3900. * lib/rubygems/remote_fetcher.rb: ditto. * test/rubygems/test_gem_remote_fetcher.rb: added testcase for CVE-2015-3900 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@51627 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/remote_fetcher.rb')
-rw-r--r--lib/rubygems/remote_fetcher.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/rubygems/remote_fetcher.rb b/lib/rubygems/remote_fetcher.rb
index 58991caeda..ed2e171d2c 100644
--- a/lib/rubygems/remote_fetcher.rb
+++ b/lib/rubygems/remote_fetcher.rb
@@ -90,7 +90,13 @@ class Gem::RemoteFetcher
rescue Resolv::ResolvError
uri
else
- URI.parse "#{uri.scheme}://#{res.target}#{uri.path}"
+ target = res.target.to_s.strip
+
+ if /\.#{Regexp.quote(host)}\z/ =~ target
+ return URI.parse "#{uri.scheme}://#{target}#{uri.path}"
+ end
+
+ uri
end
end