Skip to content

Commit

Permalink
trurl: make sure URL encoded %-hex is done lowercase
Browse files Browse the repository at this point in the history
Match how libcurl does it. Add two tests to verify.

Fixes #357
Reported-by: Peter Schilling
  • Loading branch information
bagder committed Sep 12, 2024
1 parent 63ee805 commit 867f803
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
24 changes: 24 additions & 0 deletions tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -2956,5 +2956,29 @@
"stderr": "",
"returncode": 0
}
},
{
"input": {
"arguments": [
"http://example.com/?a=%5D"
]
},
"expected": {
"stdout": "http://example.com/?a=%5d\n",
"stderr": "",
"returncode": 0
}
},
{
"input": {
"arguments": [
"http://example.com/?a=%5D&b=%5D"
]
},
"expected": {
"stdout": "http://example.com/?a=%5d&b=%5d\n",
"stderr": "",
"returncode": 0
}
}
]
2 changes: 1 addition & 1 deletion trurl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1340,7 +1340,7 @@ static char *encodequery(char *str, size_t len)
*dupe++ = in;
else {
/* encode it */
const char hex[] = "0123456789ABCDEF";
const char hex[] = "0123456789abcdef";
dupe[0]='%';
dupe[1] = hex[in>>4];
dupe[2] = hex[in & 0xf];
Expand Down

0 comments on commit 867f803

Please sign in to comment.