From 3abf409c171d60c874015d5962e79902a5f3ad1d Mon Sep 17 00:00:00 2001 From: Dmitriy Musatkin <63878209+DmitriyMusatkin@users.noreply.github.com> Date: Thu, 4 Apr 2024 09:33:23 -0700 Subject: [PATCH] switch url encode (#2910) * switch url encode for s3 crt calls * bump crt + test update --- crt/aws-crt-cpp | 2 +- src/aws-cpp-sdk-core/source/http/HttpRequest.cpp | 10 +++++++++- .../BucketAndObjectOperationTest.cpp | 2 +- .../BucketAndObjectOperationTest.cpp | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/crt/aws-crt-cpp b/crt/aws-crt-cpp index 4d9e36d5610..ea9efcb972c 160000 --- a/crt/aws-crt-cpp +++ b/crt/aws-crt-cpp @@ -1 +1 @@ -Subproject commit 4d9e36d561079506272cff59b52d998b6ae81e85 +Subproject commit ea9efcb972c869c3d5dbad751f44e56f626ff75b diff --git a/src/aws-cpp-sdk-core/source/http/HttpRequest.cpp b/src/aws-cpp-sdk-core/source/http/HttpRequest.cpp index 1b29957524f..ee23f0262d5 100644 --- a/src/aws-cpp-sdk-core/source/http/HttpRequest.cpp +++ b/src/aws-cpp-sdk-core/source/http/HttpRequest.cpp @@ -77,8 +77,16 @@ namespace Aws port << ":" << uri.GetPort(); } + // Note: GetURLEncodedPathRFC3986 does legacy mode by default, which + // leaves some reserved delimeter characters unencoded (things like + // = or , in RFC 3986 parlance). This mode can be adjusted using + // flag to use a modern GetURLEncodedPath encoding approach (i.e. + // encode everything except for a couple of known safe chars). In + // practice however CRT will never support legacy mode and will + // always need modern encoding, so be explicit here about which mode + // we use. ss << SchemeMapper::ToString(uri.GetScheme()) << SEPARATOR << uri.GetAuthority() << port.str() - << ((uri.GetPath() == "/") ? "" : uri.GetURLEncodedPathRFC3986()) + << ((uri.GetPath() == "/") ? "" : uri.GetURLEncodedPath()) << uri.GetQueryString(); request->SetPath(Aws::Crt::ByteCursorFromCString(ss.str().c_str())); diff --git a/tests/aws-cpp-sdk-s3-crt-integration-tests/BucketAndObjectOperationTest.cpp b/tests/aws-cpp-sdk-s3-crt-integration-tests/BucketAndObjectOperationTest.cpp index c7399e5f79c..35124b6c236 100644 --- a/tests/aws-cpp-sdk-s3-crt-integration-tests/BucketAndObjectOperationTest.cpp +++ b/tests/aws-cpp-sdk-s3-crt-integration-tests/BucketAndObjectOperationTest.cpp @@ -85,7 +85,7 @@ namespace //windows won't let you hard code unicode strings in a source file and assign them to a char*. Every other compiler does and I need to test this. //to get around this, this string is url encoded version of "TestUnicode中国Key". At test time, we'll convert it to the unicode string static const char* URLENCODED_UNICODE_KEY = "TestUnicode%E4%B8%AD%E5%9B%BDKey"; - static const char* URIESCAPE_KEY = "Esc ape+Me$"; + static const char* URIESCAPE_KEY = "Esc a=pe+Me$"; static const char* TEST_BUCKET_TAG = "IntegrationTestResource"; static const int TIMEOUT_MAX = 20; diff --git a/tests/aws-cpp-sdk-s3-integration-tests/BucketAndObjectOperationTest.cpp b/tests/aws-cpp-sdk-s3-integration-tests/BucketAndObjectOperationTest.cpp index d5a29dcbe6b..64d0287e570 100644 --- a/tests/aws-cpp-sdk-s3-integration-tests/BucketAndObjectOperationTest.cpp +++ b/tests/aws-cpp-sdk-s3-integration-tests/BucketAndObjectOperationTest.cpp @@ -99,7 +99,7 @@ namespace //windows won't let you hard code unicode strings in a source file and assign them to a char*. Every other compiler does and I need to test this. //to get around this, this string is url encoded version of "TestUnicode中国Key". At test time, we'll convert it to the unicode string static const char* URLENCODED_UNICODE_KEY = "TestUnicode%E4%B8%AD%E5%9B%BDKey"; - static const char* URIESCAPE_KEY = "Esc ape+Me$"; + static const char* URIESCAPE_KEY = "Esc a=pe+Me$"; static const char* CUSTOM_ENDPOINT_OVERRIDE = "beta.example.com"; static const char* TEST_BUCKET_TAG = "IntegrationTestResource";