]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
fix: remove double url_decode from the copy_source and fix url_decode
authorEmin <emin.sunacoglu@clyso.com>
Mon, 26 May 2025 14:11:19 +0000 (16:11 +0200)
committerEmin <emin.sunacoglu@clyso.com>
Tue, 27 May 2025 13:30:12 +0000 (15:30 +0200)
Signed-off-by: Emin <emin.sunacoglu@clyso.com>
src/rgw/rgw_common.cc
src/rgw/rgw_op.cc

index 25d85cabb8336fc228283956c5768dbd10a36195..92c857fd1e94cde6ac7ab0f26c8a0a7819a565e7 100644 (file)
@@ -1766,13 +1766,14 @@ std::string url_decode(const std::string_view& src_str, bool in_query)
       const char c1 = hex_to_num(*src++);
       const char c2 = hex_to_num(*src);
       if (c1 < 0 || c2 < 0) {
-        return std::string();
+        src--;
+        src--; //going back to the %
+        dest_str.push_back(*src); //add % to the target destination string
       } else {
         dest_str.push_back(c1 << 4 | c2);
       }
     }
   }
-
   return dest_str;
 }
 
index e061bbc78c1c08873968e5e45a7a41a3d45bac21..978cbbeb5c17fc73d7bfd46fe6b29a77e7742719 100644 (file)
@@ -3993,16 +3993,14 @@ int RGWPutObj::init_processing(optional_yield y) {
     copy_source_bucket_name = copy_source_bucket_name.substr(0, pos);
 #define VERSION_ID_STR "?versionId="
     pos = copy_source_object_name.find(VERSION_ID_STR);
-    if (pos == std::string::npos) {
-      copy_source_object_name = url_decode(copy_source_object_name);
-    } else {
+    if (pos != std::string::npos) {
       copy_source_version_id =
         copy_source_object_name.substr(pos + sizeof(VERSION_ID_STR) - 1);
       copy_source_object_name =
-        url_decode(copy_source_object_name.substr(0, pos));
+        copy_source_object_name.substr(0, pos);
     }
     if (copy_source_object_name.empty()) {
-      //means url_decode returned empty string so the url is formatted badly
+      //means copy_source_object_name is empty string so the url is formatted badly
       ret = -EINVAL;
       ldpp_dout(this, 5) << "x-amz-copy-source bad format" << dendl;
       return ret;