]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: url decode http query params correctly
authorYehuda Sadeh <yehuda@redhat.com>
Thu, 11 Dec 2014 17:07:10 +0000 (09:07 -0800)
committerJosh Durgin <jdurgin@redhat.com>
Fri, 16 Jan 2015 22:42:48 +0000 (14:42 -0800)
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 <giorgis@acmac.uoc.gr>
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
(cherry picked from commit 21e07eb6abacb085f81b65acd706b46af29ffc03)

src/rgw/rgw_common.cc
src/rgw/rgw_common.h

index 0a68a3b2f54fc9883561ca0f6e37297fb1548da8..dfe3361a83997ddbf60ea7e5a1e0b705a1e11fa7 100644 (file)
@@ -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 != '+') {
index 1170650b56aaef476decca088980b6b7c4bbfed2..c87169ab337edfcc7512bd669d49ac9284d9a9c9 100644 (file)
@@ -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,