aboutsummaryrefslogtreecommitdiff
path: root/tests/test-dirvish-config-playlist.el
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test-dirvish-config-playlist.el')
-rw-r--r--tests/test-dirvish-config-playlist.el15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/test-dirvish-config-playlist.el b/tests/test-dirvish-config-playlist.el
index 3876a177..d059a899 100644
--- a/tests/test-dirvish-config-playlist.el
+++ b/tests/test-dirvish-config-playlist.el
@@ -78,5 +78,20 @@ lowercase extension list."
"Boundary: a name that's just `.m3u' becomes empty after stripping."
(should (equal (cj/--playlist-sanitize-name ".m3u") "")))
+;;; cj/--playlist-name-safe-p
+
+(ert-deftest test-cj--playlist-name-safe-p-bare-name ()
+ "Normal: a bare filename is safe."
+ (should (cj/--playlist-name-safe-p "roadtrip")))
+
+(ert-deftest test-cj--playlist-name-safe-p-empty ()
+ "Boundary: an empty name is not safe."
+ (should-not (cj/--playlist-name-safe-p "")))
+
+(ert-deftest test-cj--playlist-name-safe-p-rejects-separators ()
+ "Error: any directory separator (relative, absolute, or nested) is rejected."
+ (dolist (bad '("../evil" "../../etc/cron" "/etc/passwd" "sub/dir/name"))
+ (should-not (cj/--playlist-name-safe-p bad))))
+
(provide 'test-dirvish-config-playlist)
;;; test-dirvish-config-playlist.el ends here