Fix url quoting with non-ascii (closes bug #3256)
authorStavros Sachtouris <saxtouri@admin.grnet.gr>
Tue, 26 Feb 2013 13:22:03 +0000 (15:22 +0200)
committerStavros Sachtouris <saxtouri@admin.grnet.gr>
Tue, 26 Feb 2013 14:41:55 +0000 (16:41 +0200)
Conflicts:

kamaki/clients/utils.py
version

kamaki/clients/__init__.py
kamaki/clients/utils.py

index 433b023..5ffe57f 100644 (file)
@@ -194,7 +194,7 @@ class Client(object):
             sendlog.info('perform a %s @ %s', method, self.base_url)
 
             self.http_client.url = self.base_url
-            self.http_client.path = quote(path)
+            self.http_client.path = quote(path.encode('utf8'))
             r = self.http_client.perform_request(
                 method,
                 data,
index 0060e95..c471964 100644 (file)
@@ -87,19 +87,8 @@ def path4url(*args):
     :returns: (str) a path in the form /args[0]/args[1]/...
     """
 
-    path = ''
-    for arg in args:
-        suffix = '%s' % arg
-        try:
-            while suffix[0] == '/':
-                suffix = suffix[1:]
-        except IndexError:
-            continue
-        if len(path) > 0 and path[-1] == '/':
-            path += suffix
-        else:
-            path += '/' + suffix
-    return path
+    return '/'.join([''] + [arg.decode('utf-8') if (
+        isinstance(arg, str)) else '%s' % arg for arg in args])
 
 
 def params4url(params):