From 2e5475b85fffbffa380f1e8a221499c317ce6ff1 Mon Sep 17 00:00:00 2001 From: Josh Durgin Date: Mon, 9 Sep 2013 17:19:12 -0700 Subject: [PATCH] client: escape bucket and object names used in urls Convert to utf8 since urllib doesn't handle unicode well in python 2. Signed-off-by: Josh Durgin --- radosgw_agent/client.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/radosgw_agent/client.py b/radosgw_agent/client.py index e8c8558..e9c4756 100644 --- a/radosgw_agent/client.py +++ b/radosgw_agent/client.py @@ -2,6 +2,7 @@ import boto import collections import json import requests +import urllib from boto.connection import AWSAuthConnection from boto.s3.connection import S3Connection @@ -111,8 +112,16 @@ def list_objects_in_bucket(connection, bucket_name): bucket = connection.get_bucket(bucket_name) return bucket.list() -def sync_object_intra_region(connection, bucket_name, object_name, src_zone, client_id, op_id): - return request(connection, 'put', '/{bucket_name}/{object_name}'.format(bucket_name=bucket_name,object_name=object_name), +def url_safe(component): + return urllib.quote(component.encode('utf8')) + +def sync_object_intra_region(connection, bucket_name, object_name, src_zone, + client_id, op_id): + path = '/{bucket}/{object}'.format( + bucket=url_safe(bucket_name), + object=url_safe(object_name), + ) + return request(connection, 'put', path, params={ 'rgwx-source-zone': src_zone, 'rgwx-client-id': client_id, -- 2.47.3