From: Jozef Zigmund <[email protected]> When user made typo in URL like 'http;//' instead of 'http://' then he got "undefined method `request_uri' for #<URI::Generic:0x7fb611605c60>"
https://bugzilla.redhat.com/show_bug.cgi?id=811852 --- src/app/controllers/deployables_controller.rb | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/app/controllers/deployables_controller.rb b/src/app/controllers/deployables_controller.rb index e07a603..8c007ff 100644 --- a/src/app/controllers/deployables_controller.rb +++ b/src/app/controllers/deployables_controller.rb @@ -304,17 +304,24 @@ class DeployablesController < ApplicationController end def import_xml_from_url(url) - begin - response = RestClient.get(url, :accept => :xml) - if response.code == 200 - response - end - rescue RestClient::Exception, SocketError, URI::InvalidURIError, Errno::ECONNREFUSED, Errno::ETIMEDOUT - if url.present? - flash[:error] = t('catalog_entries.flash.warning.not_valid_or_reachable', :url => url) + if url.present? + uri = URI.parse(url) + if uri.kind_of?(URI::HTTP) + begin + response = RestClient.get(url, :accept => :xml) + if response.code == 200 + response + end + rescue RestClient::Exception, SocketError, URI::InvalidURIError, Errno::ECONNREFUSED, Errno::ETIMEDOUT + flash[:error] = t('catalog_entries.flash.warning.not_valid_or_reachable', :url => url) + nil + end else - flash[:error] = t('catalog_entries.flash.warning.no_url_provided') + flash[:error] = t('catalog_entries.flash.warning.not_valid_or_reachable', :url => url) + nil end + else + flash[:error] = t('catalog_entries.flash.warning.no_url_provided') nil end end -- 1.7.11.4
