Fuco1 / dired-hacks

Collection of useful dired additions
GNU General Public License v3.0
877 stars 77 forks source link

dired-open-xdg: Argument quotes must be escaped #224

Open rythoris opened 1 month ago

rythoris commented 1 month ago

Quoting the file-name using concatenation is unsafe, and sometimes it doesn't work when there is a single-quote and spaces in the file-name. I would recommend the following changes for dired-open-xdg which uses the Emacs 29.1 shell-quote-argument function:

   (interactive)
   (if (executable-find "xdg-open")
       (let ((file (ignore-errors (dired-get-file-for-visit))))
-        (call-process-shell-command (concat "xdg-open '" (file-truename file) "'"))
+        (call-process-shell-command (concat "xdg-open " (shell-quote-argument
+                                                         (file-truename file))))
     nil)))

Quoting in this case is not that complicated and can be done using basic substitution if you want to keep it backward compatible.

ika-twb commented 3 weeks ago

I had the same problem! Could you check and see if #225 works for you? I did only minimal testing since it was just a simple change.

rythoris commented 3 weeks ago

@ika-twb yeah, that should do the trick...