From 05208f881c526e6377e59c457acb9cfe4dab479a Mon Sep 17 00:00:00 2001 From: Rupak Ganguly Date: Fri, 9 Sep 2011 16:29:29 -0400 Subject: [PATCH] Add special char. support including '?' in container and object names. --- lib/fog/storage/hp.rb | 10 ++++++++++ lib/fog/storage/requests/hp/delete_container.rb | 2 +- lib/fog/storage/requests/hp/delete_object.rb | 2 +- lib/fog/storage/requests/hp/get_container.rb | 2 +- lib/fog/storage/requests/hp/get_object.rb | 2 +- lib/fog/storage/requests/hp/head_container.rb | 2 +- lib/fog/storage/requests/hp/head_object.rb | 2 +- lib/fog/storage/requests/hp/put_container.rb | 2 +- lib/fog/storage/requests/hp/put_object.rb | 2 +- 9 files changed, 18 insertions(+), 8 deletions(-) diff --git a/lib/fog/storage/hp.rb b/lib/fog/storage/hp.rb index 1e17d54be..7d2d932f9 100644 --- a/lib/fog/storage/hp.rb +++ b/lib/fog/storage/hp.rb @@ -68,6 +68,16 @@ module Fog acl = "public-read-write" end end + + # 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 diff --git a/lib/fog/storage/requests/hp/delete_container.rb b/lib/fog/storage/requests/hp/delete_container.rb index 44d31ec3d..515ef4707 100644 --- a/lib/fog/storage/requests/hp/delete_container.rb +++ b/lib/fog/storage/requests/hp/delete_container.rb @@ -12,7 +12,7 @@ module Fog response = request( :expects => 204, :method => 'DELETE', - :path => URI.escape(name) + :path => escape_name(name) ) response end diff --git a/lib/fog/storage/requests/hp/delete_object.rb b/lib/fog/storage/requests/hp/delete_object.rb index b50a8415e..b30f45750 100644 --- a/lib/fog/storage/requests/hp/delete_object.rb +++ b/lib/fog/storage/requests/hp/delete_object.rb @@ -13,7 +13,7 @@ module Fog response = request( :expects => 204, :method => 'DELETE', - :path => "#{URI.escape(container)}/#{URI.escape(object)}" + :path => "#{escape_name(container)}/#{escape_name(object)}" ) response end diff --git a/lib/fog/storage/requests/hp/get_container.rb b/lib/fog/storage/requests/hp/get_container.rb index 8c18c121b..23603f8f2 100644 --- a/lib/fog/storage/requests/hp/get_container.rb +++ b/lib/fog/storage/requests/hp/get_container.rb @@ -33,7 +33,7 @@ module Fog response = request( :expects => 200, :method => 'GET', - :path => URI.escape(container), + :path => escape_name(container), :query => {'format' => 'json'}.merge!(options) ) response diff --git a/lib/fog/storage/requests/hp/get_object.rb b/lib/fog/storage/requests/hp/get_object.rb index a3a516991..c163371ac 100644 --- a/lib/fog/storage/requests/hp/get_object.rb +++ b/lib/fog/storage/requests/hp/get_object.rb @@ -14,7 +14,7 @@ module Fog :block => block, :expects => 200, :method => 'GET', - :path => "#{URI.escape(container)}/#{URI.escape(object)}" + :path => "#{escape_name(container)}/#{escape_name(object)}" }, false, &block) response end diff --git a/lib/fog/storage/requests/hp/head_container.rb b/lib/fog/storage/requests/hp/head_container.rb index 91e4acb4f..a18826ceb 100644 --- a/lib/fog/storage/requests/hp/head_container.rb +++ b/lib/fog/storage/requests/hp/head_container.rb @@ -17,7 +17,7 @@ module Fog response = request( :expects => 204, :method => 'HEAD', - :path => URI.escape(container), + :path => escape_name(container), :query => {'format' => 'json'} ) response diff --git a/lib/fog/storage/requests/hp/head_object.rb b/lib/fog/storage/requests/hp/head_object.rb index ce27c3ed8..a054d85d6 100644 --- a/lib/fog/storage/requests/hp/head_object.rb +++ b/lib/fog/storage/requests/hp/head_object.rb @@ -13,7 +13,7 @@ module Fog response = request({ :expects => 200, :method => 'HEAD', - :path => "#{URI.escape(container)}/#{URI.escape(object)}" + :path => "#{escape_name(container)}/#{escape_name(object)}" }, false) response end diff --git a/lib/fog/storage/requests/hp/put_container.rb b/lib/fog/storage/requests/hp/put_container.rb index b5df04ec4..a74f45171 100644 --- a/lib/fog/storage/requests/hp/put_container.rb +++ b/lib/fog/storage/requests/hp/put_container.rb @@ -13,7 +13,7 @@ module Fog :expects => [201, 202], :headers => options, :method => 'PUT', - :path => URI.escape(name) + :path => escape_name(name) ) response end diff --git a/lib/fog/storage/requests/hp/put_object.rb b/lib/fog/storage/requests/hp/put_object.rb index 91a8a45f0..71ef41470 100644 --- a/lib/fog/storage/requests/hp/put_object.rb +++ b/lib/fog/storage/requests/hp/put_object.rb @@ -19,7 +19,7 @@ module Fog :expects => 201, :headers => headers, :method => 'PUT', - :path => "#{URI.escape(container)}/#{URI.escape(object)}" + :path => "#{escape_name(container)}/#{escape_name(object)}" ) response end