bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#16984: dired-do-rename susceptible to .../~/... hijack


From: npostavs
Subject: bug#16984: dired-do-rename susceptible to .../~/... hijack
Date: Thu, 08 Dec 2016 09:39:35 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux)

Michael Albinus <address@hidden> writes:

> address@hidden writes:
>
> `tramp-quote-name' works for both local and remote file names, so you
> could remove the test `(file-remote-p filename)'.

Oh, I somehow had it in my mind that `concat' doesn't work with nil, I
must have mixed it up with `insert'.  Also, I guess most of the filename
tests should actually be looking at only the localname, so it should go
more like this:

    (defun minibuffer-maybe-quote-filename (filename)
      "Protect FILENAME from `substitute-in-file-name', as needed.
    Useful to give the user default values that won't be substituted."
      (let ((local (file-remote-p filename 'localname)))
        (if (and (not (string-prefix-p "/:" local))
                 (file-name-absolute-p filename)
                 (string-match-p "/~" local))
            (tramp-quote-name filename)
          (minibuffer--double-dollars filename))))


Regarding `tramp-quoted-name-p', you should use (string-match "\\`/:"
...) or (string-prefix-p "/:" ...), not (string-match "^/:" ...) as the
latter could get confused by newlines in filenames (of the first two, I
find the `string-prefix-p' version clearer).





reply via email to

[Prev in Thread] Current Thread [Next in Thread]