1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-03-03 14:52:21 +02:00

Add missing httpUriEncode() in S3 request.

This was not a live bug since the files currently handled by C can't have special characters in them.
This commit is contained in:
David Steele 2019-04-29 15:20:54 -04:00
parent 62b48d8a5a
commit c935b1c9e8
3 changed files with 7 additions and 3 deletions

View File

@ -49,6 +49,10 @@
<p>Add macros to create constant <code>Buffer</code> objects.</p>
</release-item>
<release-item>
<p>Add missing <code>httpUriEncode()</code> in S3 request.</p>
</release-item>
<release-item>
<p>Add <code>unsigned int</code> <code>Variant</code> type and update code to use it.</p>
</release-item>

View File

@ -336,7 +336,7 @@ storageDriverS3Request(
// Generate authorization header
storageDriverS3Auth(
this, verb, uri, query, storageDriverS3DateTime(time(NULL)), requestHeader,
this, verb, httpUriEncode(uri, true), query, storageDriverS3DateTime(time(NULL)), requestHeader,
body == NULL || bufUsed(body) == 0 ?
STRDEF("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855") :
bufHex(cryptoHashOne(HASH_TYPE_SHA256_STR, body)));

View File

@ -89,7 +89,7 @@ testS3Server(void)
// storageDriverS3NewRead() and StorageDriverS3FileRead
// -------------------------------------------------------------------------------------------------------------------------
// Ignore missing file
harnessTlsServerExpect(testS3ServerRequest(HTTP_VERB_GET, "/file.txt", NULL));
harnessTlsServerExpect(testS3ServerRequest(HTTP_VERB_GET, "/fi%26le.txt", NULL));
harnessTlsServerReply(testS3ServerResponse(404, "Not Found", NULL, NULL));
// Error on missing file
@ -543,7 +543,7 @@ testRun(void)
// storageDriverS3NewRead() and StorageDriverS3FileRead
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_PTR(
storageGetNP(storageNewReadP(s3, strNew("file.txt"), .ignoreMissing = true)), NULL, "ignore missing file");
storageGetNP(storageNewReadP(s3, strNew("fi&le.txt"), .ignoreMissing = true)), NULL, "ignore missing file");
TEST_ERROR(
storageGetNP(storageNewReadNP(s3, strNew("file.txt"))), FileMissingError,
"unable to open '/file.txt': No such file or directory");