summaryrefslogtreecommitdiff
path: root/test/src/fileio-tests.el
diff options
context:
space:
mode:
authorMattias EngdegÄrd <mattiase@acm.org>2022-07-08 15:09:16 +0200
committerMattias EngdegÄrd <mattiase@acm.org>2022-07-08 15:13:21 +0200
commit6791165b2a0e707f719efec08aad62cdf6ed8ad3 (patch)
treed98f464114aa6b60c7fa8156e26e3edb9a019585 /test/src/fileio-tests.el
parent739e3dbe050468e1d9aa0a48bfc656ae20fd8f9d (diff)
downloademacs-6791165b2a0e707f719efec08aad62cdf6ed8ad3.tar.gz
Fix file-name-case-insensitive-p in ffap (bug#56443)
Don't crash if the file name argument to file-name-case-insensitive-p, after expansion, doesn't have a parent directory. This occurs when calling ffap on something that looks like an email address. * src/fileio.c (Ffile_name_case_insensitive_p): Return nil if no file or parent directory could be found. * test/src/fileio-tests.el (fileio-tests--identity-expand-handler) (fileio--file-name-case-insensitive-p): New test.
Diffstat (limited to 'test/src/fileio-tests.el')
-rw-r--r--test/src/fileio-tests.el16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/src/fileio-tests.el b/test/src/fileio-tests.el
index c137ce06f1a..08582c8a862 100644
--- a/test/src/fileio-tests.el
+++ b/test/src/fileio-tests.el
@@ -201,4 +201,20 @@ Also check that an encoding error can appear in a symlink."
(insert-file-contents "/dev/urandom" nil nil 10)
(should (= (buffer-size) 10))))
+(defun fileio-tests--identity-expand-handler (_ file &rest _)
+ file)
+(put 'fileio-tests--identity-expand-handler 'operations '(expand-file-name))
+
+(ert-deftest fileio--file-name-case-insensitive-p ()
+ ;; Check that we at least don't crash if given nonexisting files
+ ;; without a directory (bug#56443).
+
+ ;; Use an identity file-name handler, as if called by `ffap'.
+ (let* ((file-name-handler-alist
+ '(("^mailto:" . fileio-tests--identity-expand-handler)))
+ (file "mailto:snowball@hell.com"))
+ ;; Check that `expand-file-name' is identity for this name.
+ (should (equal (expand-file-name file nil) file))
+ (file-name-case-insensitive-p file)))
+
;;; fileio-tests.el ends here