From: Zhang Shaowen Date: Tue, 4 Jul 2017 09:18:11 +0000 (+0800) Subject: rgw: replace '+' with "%20" in canonical query string for s3 v4 auth. X-Git-Tag: v13.0.0~87^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8ef21a05e6b2a8563ea37345746ade4a9cd189d7;p=ceph.git rgw: replace '+' with "%20" in canonical query string for s3 v4 auth. ( note: this patch modified: now replaces "+" with " ". mwatts@redhat.com ) Fixes: http://tracker.ceph.com/issues/20501 Signed-off-by: Zhang Shaowen --- diff --git a/src/rgw/rgw_auth_s3.cc b/src/rgw/rgw_auth_s3.cc index 4a64378dd621..e183465b95c2 100644 --- a/src/rgw/rgw_auth_s3.cc +++ b/src/rgw/rgw_auth_s3.cc @@ -501,15 +501,22 @@ static inline std::string aws4_uri_recode(const boost::string_view& src) std::string get_v4_canonical_qs(const req_info& info, const bool using_qs) { - if (info.request_params.empty()) { + const std::string *params = &info.request_params; + std::string copy_params; + if (params->empty()) { /* Optimize the typical flow. */ return std::string(); } + if (params->find_first_of('+') != std::string::npos) { + copy_params = *params; + boost::replace_all(copy_params, "+", " "); + params = ©_params; + } /* Handle case when query string exists. Step 3 described in: http://docs. * aws.amazon.com/general/latest/gr/sigv4-create-canonical-request.html */ std::map canonical_qs_map; - for (const auto& s : get_str_vec<5>(info.request_params, "&")) { + for (const auto& s : get_str_vec<5>(*params, "&")) { boost::string_view key, val; const auto parsed_pair = parse_key_value(s); if (parsed_pair) {