From 4a3fc6e06f83a34c9ac219e31abbc6bae6cb8318 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Mon, 27 Feb 2017 11:24:02 +0100 Subject: Test Helper::untaint_archive_name Signed-off-by: Florian Pritz --- t/01_untaint.t | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 t/01_untaint.t (limited to 't') 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; -- cgit v1.2.3-24-g4f1b