summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Albinus <michael.albinus@gmx.de>2021-05-03 16:52:18 +0200
committerMichael Albinus <michael.albinus@gmx.de>2021-05-03 16:52:18 +0200
commit824d1a57ec8e7c90b01af6665de5a114529170df (patch)
treeea59e5089edbcac57058d5c068425286a9a8aabf
parent46b7ce0e9c77da436a139a2a44fab3cb2bcc7649 (diff)
downloademacs-824d1a57ec8e7c90b01af6665de5a114529170df.tar.gz
emacs-824d1a57ec8e7c90b01af6665de5a114529170df.tar.bz2
emacs-824d1a57ec8e7c90b01af6665de5a114529170df.zip
Fix unquoting of file names in subprocesses (Bug#48177)
* lisp/files.el (file-name-non-special): Improve handling of inhibit-file-name-handlers. * src/callproc.c (Fcall_process, call_process): Unquote infile, error_file and output_file. (Bug#48177) * test/lisp/files-tests.el (files-tests-file-name-non-special--subprocess) (files-tests-file-name-non-special-file-name-all-completions) (files-tests-file-name-non-special-file-name-completion): Adapt tests.
-rw-r--r--lisp/files.el6
-rw-r--r--src/callproc.c13
-rw-r--r--test/lisp/files-tests.el24
3 files changed, 29 insertions, 14 deletions
diff --git a/lisp/files.el b/lisp/files.el
index 8e8fbac8dc8..2c5017a2fdc 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -7439,7 +7439,11 @@ only these files will be asked to be saved."
;; might be bound to different file name handlers, we still
;; need this.
(saved-file-name-handler-alist file-name-handler-alist)
- file-name-handler-alist
+ (inhibit-file-name-handlers
+ (cons 'file-name-non-special
+ (and (eq inhibit-file-name-operation operation)
+ inhibit-file-name-handlers)))
+ (inhibit-file-name-operation operation)
;; Some operations respect file name handlers in
;; `default-directory'. Because core function like
;; `call-process' don't care about file name handlers in
diff --git a/src/callproc.c b/src/callproc.c
index 5aa2cbafb4c..e44e243680d 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -276,6 +276,9 @@ usage: (call-process PROGRAM &optional INFILE DESTINATION DISPLAY &rest ARGS) *
else
infile = build_string (NULL_DEVICE);
+ /* Remove "/:" from INFILE. */
+ infile = remove_slash_colon (infile);
+
encoded_infile = ENCODE_FILE (infile);
filefd = emacs_open (SSDATA (encoded_infile), O_RDONLY, 0);
@@ -439,9 +442,15 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd,
current_dir = encode_current_directory ();
if (STRINGP (error_file))
- error_file = ENCODE_FILE (error_file);
+ {
+ error_file = remove_slash_colon (error_file);
+ error_file = ENCODE_FILE (error_file);
+ }
if (STRINGP (output_file))
- output_file = ENCODE_FILE (output_file);
+ {
+ output_file = remove_slash_colon (output_file);
+ output_file = ENCODE_FILE (output_file);
+ }
display_p = INTERACTIVE && nargs >= 4 && !NILP (args[3]);
diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el
index 33716577a1a..921e2c80f3a 100644
--- a/test/lisp/files-tests.el
+++ b/test/lisp/files-tests.el
@@ -302,12 +302,15 @@ be $HOME."
(file-name-unquote temporary-file-directory))))))
(ert-deftest files-tests-file-name-non-special--subprocess ()
- "Check that Bug#25949 is fixed."
- (skip-unless (executable-find "true"))
- (let ((default-directory (file-name-quote temporary-file-directory)))
- (should (zerop (process-file "true")))
- (should (processp (start-file-process "foo" nil "true")))
- (should (zerop (shell-command "true")))))
+ "Check that Bug#25949 and Bug#48177 are fixed."
+ (skip-unless (and (executable-find "true") (file-exists-p null-device)))
+ (let ((default-directory (file-name-quote temporary-file-directory))
+ (true (file-name-quote (executable-find "true")))
+ (null (file-name-quote null-device)))
+ (should (zerop (process-file true null `((:file ,null) ,null))))
+ (should (processp (start-file-process "foo" nil true)))
+ (should (zerop (shell-command true)))
+ (should (processp (make-process :name "foo" :command `(,true))))))
(defmacro files-tests--with-advice (symbol where function &rest body)
(declare (indent 3))
@@ -715,9 +718,8 @@ unquoted file names."
(file (file-name-nondirectory tmpfile))
(nospecial-file (file-name-nondirectory nospecial)))
(should-not (string-equal file nospecial-file))
- (should-not (equal (file-name-all-completions
- nospecial-file nospecial-tempdir)
- (file-name-all-completions file tmpdir)))
+ (should (equal (file-name-all-completions nospecial-file nospecial-tempdir)
+ (file-name-all-completions file tmpdir)))
(should (equal (file-name-all-completions file nospecial-tempdir)
(file-name-all-completions file tmpdir)))
(should (equal (file-name-all-completions nospecial-file tmpdir)
@@ -759,8 +761,8 @@ unquoted file names."
(file (file-name-nondirectory tmpfile))
(nospecial-file (file-name-nondirectory nospecial)))
(should-not (string-equal file nospecial-file))
- (should-not (equal (file-name-completion nospecial-file nospecial-tempdir)
- (file-name-completion file tmpdir)))
+ (should (equal (file-name-completion nospecial-file nospecial-tempdir)
+ (file-name-completion file tmpdir)))
(should (equal (file-name-completion file nospecial-tempdir)
(file-name-completion file tmpdir)))
(should (equal (file-name-completion nospecial-file tmpdir)