mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-05 03:20:39 -08:00
Check for null bytes in filenames in 'expand-file-name' (bug#49723)
* src/fileio.c (expand-file-name): Check for null bytes for both NAME and DEFAULT-DIRECTORY arguments. Also check for null bytes in buffer-local default-directory, assuming it is used. * src/coding.c (encode_file_name): Use CHECK_STRING_NULL_BYTES. * src/lisp.h (CHECK_STRING_NULL_BYTES): Add function for checking for null bytes in Lisp strings. * test/src/fileio-tests.el (fileio-test--expand-file-name-null-bytes): Add test for new changes to expand-file-name. * etc/NEWS: Announce changes.
This commit is contained in:
parent
62e870691d
commit
4e21c5f451
5 changed files with 29 additions and 3 deletions
|
|
@ -136,6 +136,15 @@ Also check that an encoding error can appear in a symlink."
|
|||
(should (and (file-name-absolute-p name)
|
||||
(not (eq (aref name 0) ?~))))))
|
||||
|
||||
(ert-deftest fileio-test--expand-file-name-null-bytes ()
|
||||
"Test that expand-file-name checks for null bytes in filenames."
|
||||
(should-error (expand-file-name (concat "file" (char-to-string ?\0) ".txt"))
|
||||
:type 'wrong-type-argument)
|
||||
(should-error (expand-file-name "file.txt" (concat "dir" (char-to-string ?\0)))
|
||||
:type 'wrong-type-argument)
|
||||
(let ((default-directory (concat "dir" (char-to-string ?\0))))
|
||||
(should-error (expand-file-name "file.txt") :type 'wrong-type-argument)))
|
||||
|
||||
(ert-deftest fileio-tests--file-name-absolute-p ()
|
||||
"Test file-name-absolute-p."
|
||||
(dolist (suffix '("" "/" "//" "/foo" "/foo/" "/foo//" "/foo/bar"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue