From 102646581c3f8238a97e6bac7748f3df750351ff Mon Sep 17 00:00:00 2001 From: Rupak Ganguly Date: Fri, 21 Oct 2011 17:43:17 -0400 Subject: [PATCH] Add fix for special chars. in CDN-enabled container names. --- lib/fog/hp/cdn.rb | 13 +++++++++++++ lib/fog/hp/requests/cdn/delete_container.rb | 2 +- lib/fog/hp/requests/cdn/post_container.rb | 2 +- lib/fog/hp/requests/cdn/put_container.rb | 2 +- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/fog/hp/cdn.rb b/lib/fog/hp/cdn.rb index d7d1e125f..d716682bb 100644 --- a/lib/fog/hp/cdn.rb +++ b/lib/fog/hp/cdn.rb @@ -17,7 +17,19 @@ module Fog request :put_container request :delete_container + module Utils + # Take care of container names with '?' in them + def escape_name(name) + if name.include?('?') + URI.escape(name).gsub('?', '%3F') + else + URI.escape(name) + end + end + end + class Mock + include Utils def self.data @data ||= Hash.new do |hash, key| @@ -44,6 +56,7 @@ module Fog end class Real + include Utils def initialize(options={}) require 'multi_json' diff --git a/lib/fog/hp/requests/cdn/delete_container.rb b/lib/fog/hp/requests/cdn/delete_container.rb index 22c58e42f..e74c6b508 100644 --- a/lib/fog/hp/requests/cdn/delete_container.rb +++ b/lib/fog/hp/requests/cdn/delete_container.rb @@ -12,7 +12,7 @@ module Fog response = request( :expects => 204, :method => 'DELETE', - :path => CGI.escape(name) + :path => escape_name(name) ) response end diff --git a/lib/fog/hp/requests/cdn/post_container.rb b/lib/fog/hp/requests/cdn/post_container.rb index 929e4054e..cff46fb90 100644 --- a/lib/fog/hp/requests/cdn/post_container.rb +++ b/lib/fog/hp/requests/cdn/post_container.rb @@ -19,7 +19,7 @@ module Fog :expects => [201, 202], :headers => options, :method => 'POST', - :path => CGI.escape(name) + :path => escape_name(name) ) response end diff --git a/lib/fog/hp/requests/cdn/put_container.rb b/lib/fog/hp/requests/cdn/put_container.rb index 53fea638e..be7c2c6cd 100644 --- a/lib/fog/hp/requests/cdn/put_container.rb +++ b/lib/fog/hp/requests/cdn/put_container.rb @@ -19,7 +19,7 @@ module Fog :expects => [201, 202], :headers => options, :method => 'PUT', - :path => CGI.escape(name) + :path => escape_name(name) ) response end