You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2011/04/08 15:20:09 UTC

svn commit: r1090241 - /incubator/libcloud/trunk/libcloud/storage/drivers/s3.py

Author: tomaz
Date: Fri Apr  8 13:20:09 2011
New Revision: 1090241

URL: http://svn.apache.org/viewvc?rev=1090241&view=rev
Log:
Escape special characters in the object name.

Modified:
    incubator/libcloud/trunk/libcloud/storage/drivers/s3.py

Modified: incubator/libcloud/trunk/libcloud/storage/drivers/s3.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/libcloud/storage/drivers/s3.py?rev=1090241&r1=1090240&r2=1090241&view=diff
==============================================================================
--- incubator/libcloud/trunk/libcloud/storage/drivers/s3.py (original)
+++ incubator/libcloud/trunk/libcloud/storage/drivers/s3.py Fri Apr  8 13:20:09 2011
@@ -15,6 +15,7 @@
 
 import time
 import httplib
+import urllib
 import copy
 import base64
 import hmac
@@ -223,9 +224,9 @@ class S3StorageDriver(StorageDriver):
         return False
 
     def delete_object(self, obj):
-        # TODO: escape object and container name
+        object_name = self._clean_name(name=obj.name)
         response = self.connection.request('/%s/%s' % (obj.container.name,
-                                                       obj.name),
+                                                       object_name),
                                            method='DELETE')
         if response.status == httplib.NO_CONTENT:
             return True
@@ -235,6 +236,10 @@ class S3StorageDriver(StorageDriver):
 
         return False
 
+    def _clean_name(self, name):
+        name = urllib.quote(name)
+        return name
+
     def _to_containers(self, obj, xpath):
         return [ self._to_container(element) for element in \
                  obj.findall(fixxpath(xpath=xpath, namespace=NAMESPACE))]