|
2022-04-04
| ||
| 11:51 | • Closed ticket [e5ed1bb28b]: Issue if URL contains numeric IPv6 address plus ... artifact: 82cad836db user: jan.nijtmans | |
| 11:16 | Fix [e5ed1bb28b]: Issue if URL contains numeric IPv6 address. http -> 2.9.6 check-in: 137067079a user: jan.nijtmans tags: core-8-6-branch | |
|
2022-04-03
| ||
| 17:30 | • New ticket [e5ed1bb28b] Issue if URL contains numeric IPv6 address. artifact: 2f3f6b3447 user: anonymous | |
Issue if URL contains numeric IPv6 address
Closed / Fixede5ed1bb28bd172a94930d7c7a190b4d524521f69Created 5 years agoUpdated 5 years ago
Descriptionplain2022-04-03 17:30:13
While procedure "::http::geturl" is working correctly with host names and numeric IPv4 addresses (e.g. loopback address "127.0.0.1"), it is failing with numeric IPv6 addresses (e.g. loopback address "::1").
Example:
package require http
set url "http://\[::1\]:8080/0/0/0.png"
set rc [catch {::http::geturl $url} token]
set ncode [::http::ncode $token]
set data [::http::data $token]
Result:
rc = 0
token = ::http::1
ncode = 400
data = "<h1>Bad Message 400</h1><pre>reason: Bad HostPort</pre>"
Reason:
URL's host and port parts are concatenated and saved in local variable "state(socketinfo)" by statement
set state(socketinfo) $host:$port
-> state(socketinfo) = ::1:8080
and later on, host and port are restored from local variable by following statements
set host [lindex [split $state(socketinfo) :] 0]
set port [lindex [split $state(socketinfo) :] 1]
-> host = ""
port = ""
Solution:
Restoring host and port from local variable by statement
regexp {(.+):([^:]+)} $state(socketinfo) {} host port
-> host = "::1"
port = "8080"
is working with IPv4 and IPv6 addresses as well as with host names:
set rc [catch {::http::geturl $url} token]
set ncode [::http::ncode $token]
set data [::http::data $token]
Result:
rc = 0
token = ::http::1
ncode = 200
data = <response as expected from web server>
Referenced by1
137067079aFix [e5ed1bb28b]: Issue if URL contains numeric IPv6 address. http -> 2.9.6 check-in2022-04-04 11:16:27
jan.nijtmanswiki2022-04-04 11:51:21
Fixed in all branches now.
Thanks!
Log in (anonymous is fine) to add a comment.