Re: How is default-directory a safe variable?

packrat386 <[email protected]> Fri, 10 Jul 2026 13:33:00 +0000
Newsgroups gmane.emacs.help
Message-ID <87cxwvynp2.fsf@fg-ct>
"Antonio Romano" <[email protected]> writes:

> From the documentation of `default-directory' variable:
>
>   This variable is safe as a file local variable if its value
>   satisfies the predicate ‘stringp’.
>
> But how can this be safe? `default-directory' could point to a TRAMP
> malicious host without the user even knowing, as the value in
> .dir-locals would be read without any warning. What's the rationale
> behind this? Asking out of curiosity.

I don't think "safe" is meant here in the security sense of the word. If
it satisfies stringp then it is set and is a directory of some sort, so
you can safely treat it like a directory name. But just checking that it
is a string is not sufficient to know whether it's a good idea to write
there.