diff options
| author | Craig Jennings <c@cjennings.net> | 2026-05-23 03:31:04 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-05-23 03:31:04 -0500 |
| commit | 8fc6432d44e41787fb7f69ad792f50cc906393d5 (patch) | |
| tree | 1a0554a9c7421e234a2d6ee5117d06be4debdab1 /tests/test-dirvish-config-wrappers.el | |
| parent | beb8fed5a4143710e0a9b2a526f12aae303d2cf8 (diff) | |
| download | dotemacs-8fc6432d44e41787fb7f69ad792f50cc906393d5.tar.gz dotemacs-8fc6432d44e41787fb7f69ad792f50cc906393d5.zip | |
fix(dirvish): guard nil file and reject path-traversal playlist names
cj/set-wallpaper passed `(dired-file-name-at-point)` straight to `expand-file-name`, so running it with no file at point raised a bare `wrong-type-argument` instead of a clear error. cj/dired-create-playlist-from-marked expanded the raw playlist name under `music-dir` without checking it, so a name like "../foo" or "/etc/foo" would write outside the music directory.
I added a nil-file guard to set-wallpaper and a `cj/--playlist-name-safe-p` check that rejects any name carrying a directory separator before the path is built. Both paths now fail cleanly with a user-error. Regression tests went into the existing wrapper and playlist test files.
Diffstat (limited to 'tests/test-dirvish-config-wrappers.el')
| -rw-r--r-- | tests/test-dirvish-config-wrappers.el | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/test-dirvish-config-wrappers.el b/tests/test-dirvish-config-wrappers.el index 7072fcf7..bead4583 100644 --- a/tests/test-dirvish-config-wrappers.el +++ b/tests/test-dirvish-config-wrappers.el @@ -140,5 +140,11 @@ calls the wallpaper-setter binary." (should (member "/some/picture.jpg" call-process-args)) (should (string-match-p "Wallpaper set" msg)))) +(ert-deftest test-dirvish-set-wallpaper-no-file-errors () + "Error: with no file at point, set-wallpaper signals user-error rather +than passing nil to expand-file-name." + (cl-letf (((symbol-function 'dired-file-name-at-point) (lambda () nil))) + (should-error (cj/set-wallpaper) :type 'user-error))) + (provide 'test-dirvish-config-wrappers) ;;; test-dirvish-config-wrappers.el ends here |
