From: Yehuda Sadeh Date: Thu, 11 Dec 2014 17:07:10 +0000 (-0800) Subject: rgw: url decode http query params correctly X-Git-Tag: v0.87.1~39 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b10c0d5110547586b2edac53c267391d3d42f974;p=ceph.git rgw: url decode http query params correctly Fixes: #10271 Backport: firefly This got broken by the fix for #8702. Since we now only url_decode if we're in query, we need to specify that we're in query when decoding these args. Reported-by: Georgios Dimitrakakis Signed-off-by: Yehuda Sadeh (cherry picked from commit 21e07eb6abacb085f81b65acd706b46af29ffc03) --- diff --git a/src/rgw/rgw_common.cc b/src/rgw/rgw_common.cc index 0a68a3b2f54..dfe3361a839 100644 --- a/src/rgw/rgw_common.cc +++ b/src/rgw/rgw_common.cc @@ -509,7 +509,7 @@ int XMLArgs::parse() } string substr, nameval; substr = str.substr(pos, fpos - pos); - url_decode(substr, nameval); + url_decode(substr, nameval, true); NameVal nv(nameval); int ret = nv.parse(); if (ret >= 0) { @@ -693,14 +693,13 @@ static char hex_to_num(char c) return hex_table.to_num(c); } -bool url_decode(string& src_str, string& dest_str) +bool url_decode(string& src_str, string& dest_str, bool in_query) { const char *src = src_str.c_str(); char dest[src_str.size() + 1]; int pos = 0; char c; - bool in_query = false; while (*src) { if (*src != '%') { if (!in_query || *src != '+') { diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index 1170650b56a..c87169ab337 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -1353,7 +1353,7 @@ extern bool verify_object_permission(struct req_state *s, RGWAccessControlPolicy extern bool verify_object_permission(struct req_state *s, int perm); /** Convert an input URL into a sane object name * by converting %-escaped strings into characters, etc*/ -extern bool url_decode(string& src_str, string& dest_str); +extern bool url_decode(string& src_str, string& dest_str, bool in_query = false); extern void url_encode(const string& src, string& dst); extern void calc_hmac_sha1(const char *key, int key_len,