From 4f3d637eb1996cfdd9fff0c35b0a2c9e6a679e13 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sun, 26 Feb 2017 19:48:16 +0100 Subject: borg-restore.pl: Allow + and : in archive names Signed-off-by: Florian Pritz --- borg-restore.pl | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/borg-restore.pl b/borg-restore.pl index 3c8c0c1..0c52c9b 100755 --- a/borg-restore.pl +++ b/borg-restore.pl @@ -347,7 +347,7 @@ sub restore { $destination = Helper::untaint($destination, qr(.*)); $path = Helper::untaint($path, qr(.*)); - my $archive_name = Helper::untaint($archive->{archive}, qr([a-zA-Z0-9-]+)); + my $archive_name = Helper::untaint_archive_name($archive->{archive}); printf "Restoring %s to %s from archive %s\n", $path, $destination, $archive->{archive}; @@ -726,7 +726,7 @@ sub add_archive_name { my $self = shift; my $archive = shift; - $archive = Helper::untaint($archive, qr([a-zA-Z0-9-]+)); + $archive = Helper::untaint_archive_name($archive); my $st = $self->{dbh}->prepare('insert into `archives` (`archive_name`) values (?);'); $st->execute($archive); @@ -747,7 +747,7 @@ sub remove_archive { my $self = shift; my $archive = shift; - $archive = Helper::untaint($archive, qr([a-zA-Z0-9-]+)); + $archive = Helper::untaint_archive_name($archive); my $archive_id = $self->get_archive_id($archive); @@ -773,7 +773,7 @@ sub remove_archive { sub _prefix_archive_id { my $archive = shift; - $archive = Helper::untaint($archive, qr([a-zA-Z0-9-]+)); + $archive = Helper::untaint_archive_name($archive); return 'timestamp-'.$archive; } @@ -852,3 +852,8 @@ sub untaint { $data =~ m/^($regex)$/ or die "Failed to untaint: $data"; return $1; } + +sub untaint_archive_name { + my $archive = shift; + return Helper::untaint($archive, qr([a-zA-Z0-9-:+]+)); +} -- cgit v1.2.3-24-g4f1b