From dfcd99567e925bd6565ef4676c560f6c8c89e683 Mon Sep 17 00:00:00 2001 From: devicenull Date: Fri, 18 Jul 2014 10:25:51 -0400 Subject: [PATCH] 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 (cherry picked from commit 4a63396ba1611ed36cccc8c6d0f5e6e3e13d83ee) --- src/rgw/rgw_common.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/rgw/rgw_common.cc b/src/rgw/rgw_common.cc index 58913ccbaf0dd..5a1043f31f20c 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++; -- 2.39.5