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

From: Eli Zaretskii <[email-masked]>
Date: Thu, 08 Dec 2016 18:00:16 +0200

> From: [email-masked]
> Cc: [email-masked],  Eli Zaretskii <[email-masked]>,  [email-masked]
> Date: Thu, 08 Dec 2016 09:39:35 -0500
> 
>     (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))))

Is the argument guaranteed to come from expand-file-name?  If not, it
should also accept file names matching "\~" on MS platforms.

Thanks.