]> 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 17:03:28 +0000 (13:03 -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 33b6416867772a7672d773be85753f58147bb7d6..3ba07361c19f626a4f8835c8ad6c628e6473c2c8 100644 (file)
@@ -1723,13 +1723,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 2b580236ced7fc76fbfba79a5b6e5c34d8a3119a..2c0076b47d3c713b95286fbcda39ddfa216d4989 100644 (file)
@@ -3820,16 +3820,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;