summaryrefslogtreecommitdiffstats
path: root/t/01_untaint.t
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2017-02-27 11:24:02 +0100
committerFlorian Pritz <bluewind@xinu.at>2017-02-27 11:24:02 +0100
commit4a3fc6e06f83a34c9ac219e31abbc6bae6cb8318 (patch)
tree9b9379e28778bc50648500b8d1990be9194f406c /t/01_untaint.t
parent89e65e8533efd78fc7d616dc9dc4c42083ba99df (diff)
downloadApp-BorgRestore-4a3fc6e06f83a34c9ac219e31abbc6bae6cb8318.tar.gz
App-BorgRestore-4a3fc6e06f83a34c9ac219e31abbc6bae6cb8318.tar.xz
Test Helper::untaint_archive_name
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 't/01_untaint.t')
-rw-r--r--t/01_untaint.t18
1 files changed, 18 insertions, 0 deletions
diff --git a/t/01_untaint.t b/t/01_untaint.t
new file mode 100644
index 0000000..9d2fde1
--- /dev/null
+++ b/t/01_untaint.t
@@ -0,0 +1,18 @@
+use strict;
+use warnings;
+
+use Test::More;
+use Test::Exception;
+
+use App::BorgRestore::Helper;
+
+ok(App::BorgRestore::Helper::untaint_archive_name('abc-1234:5+1') eq 'abc-1234:5+1');
+ok(App::BorgRestore::Helper::untaint_archive_name('abc') eq 'abc');
+
+dies_ok(sub{App::BorgRestore::Helper::untaint_archive_name('abc`"\'')}, 'special chars not allowed');
+dies_ok(sub{App::BorgRestore::Helper::untaint_archive_name('abc`')}, 'special chars not allowed');
+dies_ok(sub{App::BorgRestore::Helper::untaint_archive_name('abc"')}, 'special chars not allowed');
+dies_ok(sub{App::BorgRestore::Helper::untaint_archive_name('abc\'')}, 'special chars not allowed');
+
+
+done_testing;