Revert "rgw: avoid re-encoding already encoded query strings in AWS4 auth"

Signed-off-by: Javier M. Mellid <jmunhoz@igalia.com>
This commit is contained in:
Javier M. Mellid 2015-11-05 11:54:43 +01:00
parent 52e601b347
commit 537e5493fb
2 changed files with 10 additions and 17 deletions

View File

@ -974,23 +974,16 @@ static bool char_needs_url_encoding(char c)
return false;
}
void url_encode(const string& src, string& dst, bool in_query)
void url_encode(const string& src, string& dst)
{
const char *p = src.c_str();
for (unsigned i = 0; i < src.size(); i++, p++) {
if (*p == '%' && in_query && (i + 2) < src.size()) {
/* keep %AB as it is */
dst.append(p, 3);
i += 2;
p += 2;
} else {
if (char_needs_url_encoding(*p)) {
escape_char(*p, dst);
continue;
}
dst.append(p, 1);
if (char_needs_url_encoding(*p)) {
escape_char(*p, dst);
continue;
}
dst.append(p, 1);
}
}

View File

@ -2982,10 +2982,10 @@ int RGW_Auth_S3::authorize_v4(RGWRados *store, struct req_state *s)
getline(kv, key, '=');
getline(kv, val, '=');
if (!using_qs || key != "X-Amz-Signature") {
string key_enc, val_enc;
url_encode(key, key_enc, true);
url_encode(val, val_enc, true);
canonical_qs_map[key_enc] = val_enc;
string key_enc, val_enc;
url_encode(key, key_enc);
url_encode(val, val_enc);
canonical_qs_map[key_enc] = val_enc;
}
}