summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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;