mirror of
https://github.com/curl/curl.git
synced 2026-08-12 14:50:58 +03:00
http_aws_sigv4: canonicalise valueless query params
Fixes #8107 Closes #12244
This commit is contained in:
parent
2c8f4c87e1
commit
bbba69dada
2 changed files with 13 additions and 4 deletions
|
|
@ -456,6 +456,7 @@ static CURLcode canon_query(struct Curl_easy *data,
|
|||
for(i = 0; !result && (i < entry); i++, ap++) {
|
||||
size_t len;
|
||||
const char *q = ap->p;
|
||||
bool found_equals = false;
|
||||
if(!ap->len)
|
||||
continue;
|
||||
for(len = ap->len; len && !result; q++, len--) {
|
||||
|
|
@ -467,9 +468,13 @@ static CURLcode canon_query(struct Curl_easy *data,
|
|||
case '.':
|
||||
case '_':
|
||||
case '~':
|
||||
/* allowed as-is */
|
||||
result = Curl_dyn_addn(dq, q, 1);
|
||||
break;
|
||||
case '=':
|
||||
/* allowed as-is */
|
||||
result = Curl_dyn_addn(dq, q, 1);
|
||||
found_equals = true;
|
||||
break;
|
||||
case '%':
|
||||
/* uppercase the following if hexadecimal */
|
||||
|
|
@ -497,7 +502,11 @@ static CURLcode canon_query(struct Curl_easy *data,
|
|||
}
|
||||
}
|
||||
}
|
||||
if(i < entry - 1) {
|
||||
if(!result && !found_equals) {
|
||||
/* queries without value still need an equals */
|
||||
result = Curl_dyn_addn(dq, "=", 1);
|
||||
}
|
||||
if(!result && i < entry - 1) {
|
||||
/* insert ampersands between query pairs */
|
||||
result = Curl_dyn_addn(dq, "&", 1);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue