]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fix decoding + characters in URL
authordevicenull <dn@devicenull.org>
Fri, 18 Jul 2014 14:25:51 +0000 (10:25 -0400)
committerYehuda Sadeh <yehuda@redhat.com>
Fri, 18 Jul 2014 20:47:49 +0000 (13:47 -0700)
Fixes: #8702
Backport: firefly

Only decode + characters to spaces if we're in a query argument. The +
query argument.  The + => ' ' translation is not correct for
file/directory names.

Resolves http://tracker.ceph.com/issues/8702

Reviewed-by: Yehuda Sadeh <yehuda@redhat.com>
Signed-off-by: Brian Rak <dn@devicenull.org>
src/rgw/rgw_common.cc

index 0bf25922f01c60e47e7d44fbc11bc0debb01184b..f91e7a1d82fc61108ef38c9e616a16a49ef84f25 100644 (file)
@@ -697,13 +697,15 @@ bool url_decode(string& src_str, string& dest_str)
   int pos = 0;
   char c;
 
+  bool in_query = false;
   while (*src) {
     if (*src != '%') {
-      if (*src != '+') {
-       dest[pos++] = *src++;
+      if (!in_query || *src != '+') {
+        if (*src == '?') in_query = true;
+        dest[pos++] = *src++;
       } else {
-       dest[pos++] = ' ';
-       ++src;
+        dest[pos++] = ' ';
+        ++src;
       }
     } else {
       src++;