Skip to content

Commit 1510987

Browse files
committed
fix: remove double url_decode from the copy_source and fix url_decode
Signed-off-by: Emin <[email protected]>
1 parent c43ea62 commit 1510987

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/rgw/rgw_common.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1766,13 +1766,14 @@ std::string url_decode(const std::string_view& src_str, bool in_query)
17661766
const char c1 = hex_to_num(*src++);
17671767
const char c2 = hex_to_num(*src);
17681768
if (c1 < 0 || c2 < 0) {
1769-
return std::string();
1769+
src--;
1770+
src--; //going back to the %
1771+
dest_str.push_back(*src); //add % to the target destination string
17701772
} else {
17711773
dest_str.push_back(c1 << 4 | c2);
17721774
}
17731775
}
17741776
}
1775-
17761777
return dest_str;
17771778
}
17781779

src/rgw/rgw_op.cc

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3993,16 +3993,14 @@ int RGWPutObj::init_processing(optional_yield y) {
39933993
copy_source_bucket_name = copy_source_bucket_name.substr(0, pos);
39943994
#define VERSION_ID_STR "?versionId="
39953995
pos = copy_source_object_name.find(VERSION_ID_STR);
3996-
if (pos == std::string::npos) {
3997-
copy_source_object_name = url_decode(copy_source_object_name);
3998-
} else {
3996+
if (pos != std::string::npos) {
39993997
copy_source_version_id =
40003998
copy_source_object_name.substr(pos + sizeof(VERSION_ID_STR) - 1);
40013999
copy_source_object_name =
4002-
url_decode(copy_source_object_name.substr(0, pos));
4000+
copy_source_object_name.substr(0, pos);
40034001
}
40044002
if (copy_source_object_name.empty()) {
4005-
//means url_decode returned empty string so the url is formatted badly
4003+
//means copy_source_object_name is empty string so the url is formatted badly
40064004
ret = -EINVAL;
40074005
ldpp_dout(this, 5) << "x-amz-copy-source bad format" << dendl;
40084006
return ret;

0 commit comments

Comments
 (0)