summaryrefslogtreecommitdiff
path: root/lib/rubygems/gemcutter_utilities.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rubygems/gemcutter_utilities.rb')
-rw-r--r--lib/rubygems/gemcutter_utilities.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/rubygems/gemcutter_utilities.rb b/lib/rubygems/gemcutter_utilities.rb
index 9dbc18ba98..6a4da9e983 100644
--- a/lib/rubygems/gemcutter_utilities.rb
+++ b/lib/rubygems/gemcutter_utilities.rb
@@ -56,8 +56,10 @@ module Gem::GemcutterUtilities
##
# Creates an RubyGems API to +host+ and +path+ with the given HTTP +method+.
+ #
+ # If +allowed_push_host+ metadata is present, then it will only allow that host.
- def rubygems_api_request(method, path, host = nil, &block)
+ def rubygems_api_request(method, path, host = nil, allowed_push_host = nil, &block)
require 'net/http'
self.host = host if host
@@ -66,6 +68,11 @@ module Gem::GemcutterUtilities
terminate_interaction 1 # TODO: question this
end
+ if allowed_push_host and self.host != allowed_push_host
+ alert_error "#{self.host.inspect} is not allowed by the gemspec, which only allows #{allowed_push_host.inspect}"
+ terminate_interaction 1
+ end
+
uri = URI.parse "#{self.host}/#{path}"
request_method = Net::HTTP.const_get method.to_s.capitalize