You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-17 01:12:23 +02:00
Encode key in HTTP query.
The key also needs to be encoded (not just the value). This is not currently an issue because none of the keys in use require encoding.
This commit is contained in:
@ -261,7 +261,7 @@ httpQueryRender(const HttpQuery *this, HttpQueryRenderParam param)
|
|||||||
strCatZ(result, "&");
|
strCatZ(result, "&");
|
||||||
|
|
||||||
strCatFmt(
|
strCatFmt(
|
||||||
result, "%s=%s", strZ(key),
|
result, "%s=%s", strZ(httpUriEncode(key, false)),
|
||||||
param.redact && httpQueryRedact(this, key) ?
|
param.redact && httpQueryRedact(this, key) ?
|
||||||
"<redacted>" : strZ(httpUriEncode(httpQueryGet(this, key), false)));
|
"<redacted>" : strZ(httpUriEncode(httpQueryGet(this, key), false)));
|
||||||
}
|
}
|
||||||
|
@ -177,14 +177,16 @@ testRun(void)
|
|||||||
TEST_ERROR(httpQueryNewStr(STRDEF("a=b&c")), FormatError, "invalid key/value 'c' in query 'a=b&c'");
|
TEST_ERROR(httpQueryNewStr(STRDEF("a=b&c")), FormatError, "invalid key/value 'c' in query 'a=b&c'");
|
||||||
|
|
||||||
HttpQuery *query2 = NULL;
|
HttpQuery *query2 = NULL;
|
||||||
TEST_ASSIGN(query2, httpQueryNewStr(STRDEF("?a=%2Bb&c=d%3D")), "query from string");
|
TEST_ASSIGN(query2, httpQueryNewStr(STRDEF("?a%2F=%2Bb&c=d%3D")), "query from string");
|
||||||
TEST_RESULT_STR_Z(httpQueryRenderP(query2), "a=%2Bb&c=d%3D", "render query");
|
|
||||||
|
TEST_RESULT_VOID(FUNCTION_LOG_OBJECT_FORMAT(query2, httpQueryToLog, logBuf, sizeof(logBuf)), "httpQueryToLog");
|
||||||
|
TEST_RESULT_Z(logBuf, "{a/: '+b', c: 'd='}", "check log");
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------------------------------------------
|
||||||
TEST_TITLE("merge queries");
|
TEST_TITLE("merge queries");
|
||||||
|
|
||||||
TEST_RESULT_STR_Z(
|
TEST_RESULT_STR_Z(
|
||||||
httpQueryRenderP(httpQueryMerge(query, query2)), "a=%2Bb&c=d%3D&key1=value%201%3F&key2=value2a", "render merge");
|
httpQueryRenderP(httpQueryMerge(query, query2)), "a%2F=%2Bb&c=d%3D&key1=value%201%3F&key2=value2a", "render merge");
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------------------------------------------
|
||||||
TEST_TITLE("free query");
|
TEST_TITLE("free query");
|
||||||
|
Reference in New Issue
Block a user