Subject: bug#48177: 28.0.50; process-file doesn't correctly handle quoted file names for INFILE

From: Michael Albinus <[email-masked]>
Date: Mon, 03 May 2021 15:51:52 +0200

Philipp Stephani <[email-masked]> writes:

>> > Evaluate something like
>> >
>> > (process-file "/:/bin/true" "/:/dev/null")
>> >
>> > This gives an error
>> >
>> > (file-missing "Opening process input file" "No such file or directory" "/:/dev/null")
>> >
>> > Other magic filenames for INFILE (such as "/ssh:localhost:/dev/null")
>> > work as expected.  The docstring for `process-file' says that INFILE is
>> > handled by filename handlers, so I think this should work for quoted
>> > filenames as well.
>> >
>>
>> Same for
>> (process-file "/:/bin/true" nil '((:file "/:/dev/null") "/dev/null"))
>
> Other forms that I think should work, but fail:
>
> (let ((default-directory "/:/usr/"))
>   (process-file "/:/bin/true" nil '(t "/:/dev/null")))
>
> (let ((temporary-file-directory "/:/tmp/"))
>   (process-file "/:/bin/true" nil '(t "/dev/null")))

The appended patch shall fix this, could you pls test?

Best regards, Michael.

diff --git a/lisp/files.el b/lisp/files.el
index 8e8fbac8dc..7b6e186257 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -7439,7 +7439,11 @@ file-name-non-special
         ;; 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 5aa2cbafb4..e44e243680 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -276,6 +276,9 @@ DEFUN ("call-process", Fcall_process, Scall_process, 1, MANY, 0,
   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]);