Skip to content

Commit

Permalink
trurl: disable URL encoding when setting a host to an IPv6 address
Browse files Browse the repository at this point in the history
Fixes #279
Closes #280
  • Loading branch information
bagder committed Apr 18, 2024
1 parent 6ec4316 commit 5cbe3e3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -2430,5 +2430,19 @@
}
]
}
},
{
"input": {
"arguments": [
"example.com",
"--set",
"host=[::1]"
]
},
"expected": {
"stdout": "http://[::1]/\n",
"stderr": "",
"returncode": 0
}
}
]
3 changes: 3 additions & 0 deletions trurl.c
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,9 @@ static const struct var *setone(CURLU *uh, const char *setline,
v = comp2var(setline, vlen);
if(v) {
CURLUcode rc;
if((v->part == CURLUPART_HOST) && ('[' == ptr[1]))
/* when setting an IPv6 numerical address, disable URL encoding */
urlencode = false;
rc = curl_url_set(uh, v->part, ptr[1] ? &ptr[1] : NULL,
(o->curl ? 0 : CURLU_NON_SUPPORT_SCHEME)|
(urlencode ? CURLU_URLENCODE : 0) );
Expand Down

0 comments on commit 5cbe3e3

Please sign in to comment.