]> 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:41:53 +0000 (14:41 -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 5a1043f31f20ccd41dfc8deea08a2ab5ec96a35f..36b8ed382899c544357a9e2584f3a311ba24f0e4 100644 (file)
@@ -506,7 +506,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) {
@@ -690,14 +690,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 4d7a118f2be78478e040b1da43ce92c81ec26059..432e82a39790c61faedd49a4b7437d1f35a20de3 100644 (file)
@@ -1343,7 +1343,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,