return false;
}
-void url_encode(const string& src, string& dst)
+void url_encode(const string& src, string& dst, bool in_query)
{
const char *p = src.c_str();
for (unsigned i = 0; i < src.size(); i++, p++) {
- if (char_needs_url_encoding(*p)) {
- escape_char(*p, dst);
- continue;
- }
+ 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);
+ dst.append(p, 1);
+ }
}
}
/** Convert an input URL into a sane object name
* by converting %-escaped strings into characters, etc*/
extern bool url_decode(const string& src_str, string& dest_str, bool in_query = false);
-extern void url_encode(const string& src, string& dst);
+extern void url_encode(const string& src, string& dst, bool in_query = false);
/* destination should be CEPH_CRYPTO_HMACSHA1_DIGESTSIZE bytes long */
extern void calc_hmac_sha1(const char *key, int key_len,
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, true);
+ url_encode(val, val_enc, true);
+ canonical_qs_map[key_enc] = val_enc;
}
}