Merge pull request #234 from rhansen/url-parsing

Fix URL parsing for IPv6 URLs and pathless URLs
This commit is contained in:
Sandro 2020-07-06 00:33:22 +02:00 committed by GitHub
commit b6770a4d9f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2000,9 +2000,8 @@ sub geturl {
$proxy =~ s%^https?://%%i;
$url =~ s%^https?://%%i;
$server = $url;
$server =~ s%/.*%%;
$url = "/" unless $url =~ m%/%;
$url =~ s%^[^/]*/%%;
$server =~ s%[?/].*%%;
$url =~ s%^[^?/]*/?%%;
opt('fw') && debug("opt(fw = %s)", opt('fw'));
$globals{'fw'} && debug("glo fw = %s", $globals{'fw'});
@ -2022,11 +2021,14 @@ sub geturl {
## determine peer and port to use.
$peer = $proxy || $server;
$peer =~ s%/.*%%;
$port = $peer;
$port =~ s%^.*:%%;
$port = $default_port unless $port =~ /^\d+$/;
$peer =~ s%:.*$%%;
$peer =~ s%[?/].*%%;
if ($peer =~ /^\[([^]]+)\](?::(\d+))?$/ || $peer =~ /^([^:]+)(?::(\d+))?/) {
$peer = $1;
$port = $2 // $default_port;
} else {
failed("unable to extract host and port from %s", $peer);
return undef;
}
$request = "$method ";
if (!$use_ssl) {