]> git.apps.os.sepia.ceph.com Git - ceph.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)
committerCasey Bodley <cbodley@redhat.com>
Thu, 19 Jun 2025 19:00:49 +0000 (15:00 -0400)
Signed-off-by: Emin <emin.sunacoglu@clyso.com>
(cherry picked from commit 1510987b8606d8906ba53d4f343a788209707bcf)

src/rgw/rgw_common.cc
src/rgw/rgw_op.cc

index c11521f8cbf71d24cf39f7ea5dbc95ecf657cbbb..b1f07d092d2d1c873ae58b78523f9e36d891d1be 100644 (file)
@@ -1765,13 +1765,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 2eda52235a47b005eed6188db86bd24dfdfbd2ee..b2a7feff487889d0f50147b2970ab50d9a5966b9 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;