btrbk: bugfix: vinfo(): correctly parse url, using check_url()

pull/88/head
Axel Burri 2016-04-25 15:10:00 +02:00
parent 357b72bd3f
commit 702ee8950e
1 changed files with 17 additions and 14 deletions

31
btrbk
View File

@ -1432,27 +1432,30 @@ sub vinfo($;$)
my $config = shift; my $config = shift;
my %info; my %info;
my $name = $url; my ($url_prefix, $path) = check_url($url);
die "invalid url: $url" unless(defined($path));
my $name = $path;
$name =~ s/^.*\///; $name =~ s/^.*\///;
$name = '/' if($name eq "");
%info = ( %info = (
URL => $url, URL => $url_prefix . $path,
NAME => $name, NAME => $name,
PATH => $url, PATH => $path,
PRINT => $url, PRINT => $path,
URL_PREFIX => "", URL_PREFIX => $url_prefix,
); );
if($url =~ /^ssh:\/\/(\S+?)(\/\S+)$/) { if($url_prefix) {
my ($host, $path) = ($1, $2); my $host = $url_prefix;
die unless($host =~ s/^ssh:\/\///);
%info = ( %info = (
%info, %info,
HOST => $host, HOST => $host,
PATH => $path, PRINT => "$host:$path",
PRINT => "$host:$path", RSH_TYPE => "UNKNOWN",
URL_PREFIX => "ssh://$host", RSH => [ '/bin/false' ],
RSH_TYPE => "UNKNOWN",
RSH => [ '/bin/false' ],
); );
if($config) { if($config) {
my $ssh_port = config_key($config, "ssh_port"); my $ssh_port = config_key($config, "ssh_port");