all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Antero Mejr <antero@mailbox.org>
Cc: 61901@debbugs.gnu.org
Subject: bug#61901: 30.0.50; [PATCH v3] Add safe-local-variable-directories variable.
Date: Tue, 25 Apr 2023 20:23:53 +0300	[thread overview]
Message-ID: <83jzxzvpsm.fsf@gnu.org> (raw)
In-Reply-To: <87354nlxug.fsf@mailbox.org> (bug-gnu-emacs@gnu.org)

> Date: Tue, 25 Apr 2023 16:40:07 +0000
> From:  Antero Mejr via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
> 
> Updated safe-local-variable-directories patch onto master and added bug
> number to commit message.

Thanks, see some comments below.

> Also should I use git --reroll-count to make v2 patches, v3, etc?

You don't have to.  The version part is removed by "git am" anyway,
and it is not important for patch review here.

> --- a/doc/lispref/variables.texi
> +++ b/doc/lispref/variables.texi
> @@ -1977,6 +1977,13 @@ this can be controlled by using this variable, which is a list of
>  symbols.
>  @end defvar
>  
> +@defvar safe-local-variable-directories
> +This is a list of directories where local variables are always enabled.
> +Directory-local variables loaded from these directories, such as the
> +variables in @file{.dir-locals.el}, will be enabled even if they are
> +risky.
> +@end defvar

This variable should also be documented in the Emacs user manual, not
only in the ELisp Reference manual -- it's a user option, and a very
important one at that.

> ++++
> +** New variable 'safe-local-variable-directories'.
> +This variable is used to to permanently trust directories containing
> +risky directory-local variables.

I would rephrase:

  This variable names directories in which Emacs will treat all
  directory-local variables as safe.

>  ALL-VARS is the list of all variables to be set up.
> @@ -3734,7 +3744,9 @@ n  -- to ignore the local variables list.")
>  !  -- to apply the local variables list, and permanently mark these
>        values (*) as safe (in the future, they will be set automatically.)
>  i  -- to ignore the local variables list, and permanently mark these
> -      values (*) as ignored\n\n")
> +      values (*) as ignored
> ++  -- to apply the local variables list, and permanently trust all
> +      directory-local variables in this directory\n\n")

I would remove the "permanently" part, it would just confuse here.

> @@ -3908,6 +3924,7 @@ DIR-NAME is the name of the associated directory.  Otherwise it is nil."
>  		  (null unsafe-vars)
>  		  (null risky-vars))
>  	     (memq enable-local-variables '(:all :safe))
> +             (member dir-name safe-local-variable-directories)

If you use 'member' for this test, then (a) the documentation of
safe-local-variable-directories should explicitly say that the
directories in the list must be in full absolute form, and (b) we
should consider the various issues with file names that are not
'equal' as strings, but still name the same directory, such as
letter-case differences on case-insensitive filesystems.  And what
about equality of "foo/" "and "foo"?

Also, is 'dir-name' above guaranteed to be a fully-expanded absolute
file name?

> +(ert-deftest files-tests-safe-local-variable-directories ()
> +  ;; safe-local-variable-directories should be risky,
> +  ;; so use it as an arbitrary risky variable.
> +  (let ((test-alist '((safe-local-variable-directories . "some_val")))
> +        (fakedir "test1/test2")
> +        (enable-local-eval t))
> +    (with-temp-buffer
> +      (setq safe-local-variable-directories (list fakedir))

The test should use absolute directory names for directories you put
into safe-local-variable-directories.





  reply	other threads:[~2023-04-25 17:23 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-01 22:20 bug#61901: 30.0.50; [PATCH] Add permanently-enabled-local-variable-dirs variable Antero Mejr via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-02  6:57 ` Eli Zaretskii
2023-03-02 17:09   ` Antero Mejr via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-02 18:04     ` Eli Zaretskii
2023-03-14 18:46       ` Antero Mejr via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-14 19:48         ` Eli Zaretskii
2023-04-25 16:40 ` bug#61901: 30.0.50; [PATCH v3] Add safe-local-variable-directories variable Antero Mejr via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-25 17:23   ` Eli Zaretskii [this message]
2023-05-09 21:29 ` Antero Mejr via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-11 13:55   ` Eli Zaretskii
     [not found]     ` <87ilcy3mdt.fsf@mailbox.org>
2023-05-11 16:10       ` Eli Zaretskii
2023-05-11 17:49         ` Antero Mejr via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-11 18:11           ` Eli Zaretskii
2023-05-11 20:11             ` Antero Mejr via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-11 21:38               ` Antero Mejr via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-12 11:09                 ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83jzxzvpsm.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=61901@debbugs.gnu.org \
    --cc=antero@mailbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.