From 4f6523dc72a3d409fd869270e668d3685b4b30c4 Mon Sep 17 00:00:00 2001 From: "Javier M. Mellid" Date: Tue, 5 Apr 2016 16:00:10 +0200 Subject: [PATCH] rgw: aws4 uri encoding bugfix Fixes: http://tracker.ceph.com/issues/15358 Signed-off-by: Javier M. Mellid --- src/rgw/rgw_rest_s3.cc | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index e4731ba0a0b..d8119f9d421 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -3437,8 +3437,20 @@ int RGW_Auth_S3::authorize_v4(RGWRados *store, struct req_state *s) string encoded_key; string encoded_val; if (key != "X-Amz-Credential") { - aws4_uri_encode(key, encoded_key); - aws4_uri_encode(val, encoded_val); + string key_decoded; + url_decode(key, key_decoded); + if (key.length() != key_decoded.length()) { + encoded_key = key; + } else { + aws4_uri_encode(key, encoded_key); + } + string val_decoded; + url_decode(val, val_decoded); + if (val.length() != val_decoded.length()) { + encoded_val = val; + } else { + aws4_uri_encode(val, encoded_val); + } } else { encoded_key = key; encoded_val = val; -- 2.39.5