Skip to content

Commit 5cbe3e3

Browse files
committed
trurl: disable URL encoding when setting a host to an IPv6 address
Fixes #279 Closes #280
1 parent 6ec4316 commit 5cbe3e3

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

tests.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2430,5 +2430,19 @@
24302430
}
24312431
]
24322432
}
2433+
},
2434+
{
2435+
"input": {
2436+
"arguments": [
2437+
"example.com",
2438+
"--set",
2439+
"host=[::1]"
2440+
]
2441+
},
2442+
"expected": {
2443+
"stdout": "http://[::1]/\n",
2444+
"stderr": "",
2445+
"returncode": 0
2446+
}
24332447
}
24342448
]

trurl.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,9 @@ static const struct var *setone(CURLU *uh, const char *setline,
877877
v = comp2var(setline, vlen);
878878
if(v) {
879879
CURLUcode rc;
880+
if((v->part == CURLUPART_HOST) && ('[' == ptr[1]))
881+
/* when setting an IPv6 numerical address, disable URL encoding */
882+
urlencode = false;
880883
rc = curl_url_set(uh, v->part, ptr[1] ? &ptr[1] : NULL,
881884
(o->curl ? 0 : CURLU_NON_SUPPORT_SCHEME)|
882885
(urlencode ? CURLU_URLENCODE : 0) );

0 commit comments

Comments
 (0)