From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Antero Mejr via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#61901: 30.0.50; [PATCH v3] Add safe-local-variable-directories variable. Date: Thu, 11 May 2023 21:38:33 +0000 Message-ID: <874joi35wm.fsf@mailbox.org> References: <87r0rpi46l.fsf@mailbox.org> <835y8z55w5.fsf@gnu.org> <87ilcy3mdt.fsf@mailbox.org> <83wn1e4zn5.fsf@gnu.org> <87ednm3ght.fsf@mailbox.org> <83v8gy4u1j.fsf@gnu.org> <878rdu39y3.fsf@mailbox.org> Reply-To: Antero Mejr Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2489"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 61901@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu May 11 23:39:27 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pxE0T-0000Ow-AL for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 11 May 2023 23:39:25 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pxE09-0008KQ-J3; Thu, 11 May 2023 17:39:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pxE06-0008Jz-KD for bug-gnu-emacs@gnu.org; Thu, 11 May 2023 17:39:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pxE06-0004E7-C8 for bug-gnu-emacs@gnu.org; Thu, 11 May 2023 17:39:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pxE06-0000VG-7E for bug-gnu-emacs@gnu.org; Thu, 11 May 2023 17:39:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Antero Mejr Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 11 May 2023 21:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61901 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 61901-submit@debbugs.gnu.org id=B61901.16838411301916 (code B ref 61901); Thu, 11 May 2023 21:39:02 +0000 Original-Received: (at 61901) by debbugs.gnu.org; 11 May 2023 21:38:50 +0000 Original-Received: from localhost ([127.0.0.1]:53576 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pxDzt-0000Uo-IM for submit@debbugs.gnu.org; Thu, 11 May 2023 17:38:50 -0400 Original-Received: from mout-p-103.mailbox.org ([80.241.56.161]:52772) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pxDzo-0000UY-Hv for 61901@debbugs.gnu.org; Thu, 11 May 2023 17:38:48 -0400 Original-Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-103.mailbox.org (Postfix) with ESMTPS id 4QHQHw5G12z9slX; Thu, 11 May 2023 23:38:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1683841116; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=MIpj9Pa6d9yP2ab6QkvgNfHvjXKib5Yc+OB0vdnN3Q4=; b=R0pOh58VR0W4cDU4umVO5wctWZ5Vb6BeStHlSTh2UndlSBFXBtGYs16w79JfWcSAg3PoVO fNVaItN0TBjKj5rVDaF3ZZC2Vz1D03rOozckum4nqCw+RZZlFItwnAcwt2sPWsMk3Q6WRr kWVHFg0YUhX9wOvI20uwCfWeE4Ehn8ryovU6GZSAW7cUpFCKt1710C5gKupj8IJq+H7HCZ Ol3FlgmiSi5D2lsIiX/M8g+K89qRhbynO2CsXFPd0rlVi4xPku6sCeRKTXDpwi7p88Wtnl kx+ess9+RLb9mqveTG2J2U3z7gppNqnE/W4m40WCmAD5O4oBegnqHeJ6/CtSrg== In-Reply-To: <878rdu39y3.fsf@mailbox.org> (Antero Mejr's message of "Thu, 11 May 2023 20:11:16 +0000") X-MBO-RS-ID: 068f17a151ee651d1b2 X-MBO-RS-META: 68w8f7cdy5z5o8xwtcfdc9ok9jqqmtnb X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:261594 Archived-At: --=-=-= Content-Type: text/plain Antero Mejr writes: > Eli Zaretskii writes: > >>> > This actually means that I misunderstood the code. Now that I see the >>> > truth, why is it a good idea to compare directories case-sensitively >>> > when the filesystem is not? That's not something users will expect. >>> >>> To accurately assess if a directory name matches with possible >>> case-sensitivity, the process would be: >>> 1. check the case-sensitivity of the filesystem >>> 2. If case insensitive, check the case-sensitivity of each subdirectory >>> (using Windows queryCaseSensitiveInfo if applicable) >>> 3. map over the components of the directory name, checking each subdirectory >>> with the correct case-sensitivity setting >> >> We already have all that in file-equal-p. We should just use is >> there. > > Ok, patch is attached (tested on FAT32 disk). Please ignore that last patch, here is a corrected version with updated docs. Since file-equal-p handles the trailing slash, now it doesn't matter if there is/isn't one. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Handle-case-insensitivity-for-safe-local-variable-di.patch >From 175280bff2574cc7b826025903d4ca1802b7c5e6 Mon Sep 17 00:00:00 2001 From: Antero Mejr Date: Thu, 11 May 2023 19:22:49 +0000 Subject: [PATCH] Handle case-insensitivity for safe-local-variable-directories. * lisp/emacs-lisp/files.el (hack-local-variables-filter): Use file-equal-p when checking safe-local-variable-directories. * doc/lispref/variables.texi (File Local Variables): Remove sentences in safe-local-variable-directories description about case-sensitivity and trailing slash behaviors. * doc/emacs/custom.texi (Safe File Variables): Remove sentence about safe-local-variable-directories trailing slash behavior. (Bug#61901) --- doc/emacs/custom.texi | 7 +++---- doc/lispref/variables.texi | 8 +++----- lisp/files.el | 5 ++++- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/doc/emacs/custom.texi b/doc/emacs/custom.texi index d8abf81c75f..d8221f51425 100644 --- a/doc/emacs/custom.texi +++ b/doc/emacs/custom.texi @@ -1359,10 +1359,9 @@ certain directories, and skip the confirmation prompt when local variables are loaded from those directories, even if the variables are risky. The variable @code{safe-local-variable-directories} holds the list of such directories. The names of the directories in this list -must be full absolute file names, and should end in a slash. If the -variable @code{enable-remote-dir-locals} has a non-@code{nil} value, -the list can include remote directories as well (@pxref{Remote -Files}). +must be full absolute file names. If the variable +@code{enable-remote-dir-locals} has a non-@code{nil} value, the list +can include remote directories as well (@pxref{Remote Files}). @vindex enable-local-variables The variable @code{enable-local-variables} allows you to change the diff --git a/doc/lispref/variables.texi b/doc/lispref/variables.texi index b3a8cd8110c..4eda035473e 100644 --- a/doc/lispref/variables.texi +++ b/doc/lispref/variables.texi @@ -1982,11 +1982,9 @@ 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. The directories in this list must be -fully-expanded absolute file names that end in a directory separator -character. They may also be remote directories if the variable -@code{enable-remote-dir-locals} is set non-@code{nil}. Directories in -this list are matched case-sensitively, even if the filesystem is -case-sensitive. +fully-expanded absolute file names. They may also be remote +directories if the variable @code{enable-remote-dir-locals} is set +non-@code{nil}. @end defvar @defun hack-local-variables &optional handle-mode diff --git a/lisp/files.el b/lisp/files.el index 35d794f6dcf..148f47cbc97 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -3934,7 +3934,10 @@ 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) + (delq nil (mapcar (lambda (dir) + (and dir-name dir + (file-equal-p dir dir-name))) + safe-local-variable-directories)) (hack-local-variables-confirm all-vars unsafe-vars risky-vars dir-name)) (dolist (elt all-vars) -- 2.39.2 --=-=-=--