From: devicenull Date: Fri, 18 Jul 2014 14:25:51 +0000 (-0400) Subject: rgw: fix decoding + characters in URL X-Git-Tag: v0.83~12 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4a63396ba1611ed36cccc8c6d0f5e6e3e13d83ee;p=ceph.git rgw: fix decoding + characters in URL 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 Signed-off-by: Brian Rak --- diff --git a/src/rgw/rgw_common.cc b/src/rgw/rgw_common.cc index 0bf25922f01c6..f91e7a1d82fc6 100644 --- a/src/rgw/rgw_common.cc +++ b/src/rgw/rgw_common.cc @@ -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++;