Skip to content

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

@rythoris

Description

@rythoris

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions