btrbk: bugfix: handle corner case: url="ssh://my.host" (without trailing slash)

As we allow <url> to be specified as "<hostname>:<directory>", an URL
"ssh://my.host" (without trailing slash) was parsed as hostname="ssh",
directory="/my.host".
pull/245/head
Axel Burri 2018-07-09 16:13:48 +02:00
parent c2022a5b2f
commit 669a34357a
1 changed files with 5 additions and 2 deletions

3
btrbk
View File

@ -3145,9 +3145,12 @@ sub check_url($;@)
my %opts = @_; my %opts = @_;
my $url_prefix = ""; my $url_prefix = "";
if($url =~ /^ssh:\/\//) {
if($url =~ s/^(ssh:\/\/($ip_addr_match|$host_name_match))\//\//) { if($url =~ s/^(ssh:\/\/($ip_addr_match|$host_name_match))\//\//) {
$url_prefix = $1; $url_prefix = $1;
} }
# if no match, treat it as file and let check_file() print errors
}
elsif($url =~ s/^($ip_addr_match|$host_name_match)://) { elsif($url =~ s/^($ip_addr_match|$host_name_match)://) {
# convert "my.host.com:/my/path" to ssh url # convert "my.host.com:/my/path" to ssh url
$url_prefix = "ssh://" . $1; $url_prefix = "ssh://" . $1;