]> git.eshelyaron.com Git - emacs.git/commitdiff
trusted-content: Adjust the last patch based on preliminary feedback
authorStefan Monnier <monnier@iro.umontreal.ca>
Sun, 15 Dec 2024 22:05:55 +0000 (17:05 -0500)
committerEshel Yaron <me@eshelyaron.com>
Mon, 23 Dec 2024 14:59:18 +0000 (15:59 +0100)
* lisp/files.el (trusted-content): Rename from `trusted-files`.
Update all references.

* lisp/progmodes/elisp-mode.el (lisp-interaction-mode):
* lisp/ielm.el (inferior-emacs-lisp-mode):
* lisp/simple.el (read--expression): Set `trusted-content` since
these buffers contain code that the user presumably intends to run anyway.
(elisp--safe-macroexpand-all): Make the warning more discreet.

(cherry picked from commit 8b6c6cffd1f772301e89353de5e057835af18a30)

lisp/files.el
lisp/ielm.el
lisp/progmodes/elisp-mode.el
lisp/simple.el

index f9889762148d5729a6d90d839cd48493efa6831b..75b951dcdc0aca304c6e30d7d91cb24f89f0879f 100644 (file)
@@ -712,7 +712,7 @@ buffer contents as untrusted.
 This variable might be subject to change without notice.")
 (put 'untrusted-content 'permanent-local t)
 
-(defcustom trusted-files nil
+(defcustom trusted-content nil
   "List of files and directories whose content we trust.
 Be extra careful here since trusting means that Emacs might execute the
 code contained within those files and directories without an explicit
@@ -730,12 +730,12 @@ all files, which opens a gaping security hole."
   :type '(choice (repeat :tag "List" file)
                  (const :tag "Trust everything (DANGEROUS!)" :all))
   :version "30.1")
-(put 'trusted-files 'risky-local-variable t)
+(put 'trusted-content 'risky-local-variable t)
 
 (defun trusted-content-p ()
   "Return non-nil if we trust the contents of the current buffer.
 Here, \"trust\" means that we are willing to run code found inside of it.
-See also `trusted-files'."
+See also `trusted-content'."
   ;; We compare with `buffer-file-truename' i.s.o `buffer-file-name'
   ;; to try and avoid marking as trusted a file that's merely accessed
   ;; via a symlink that happens to be inside a trusted dir.
@@ -744,14 +744,14 @@ See also `trusted-files'."
        (with-demoted-errors "trusted-content-p: %S"
          (let ((exists (file-exists-p buffer-file-truename)))
            (or
-            (eq trusted-files :all)
+            (eq trusted-content :all)
             ;; We can't avoid trusting the user's init file.
             (if (and exists user-init-file)
                 (file-equal-p buffer-file-truename user-init-file)
               (equal buffer-file-truename user-init-file))
             (let ((file (abbreviate-file-name buffer-file-truename))
                   (trusted nil))
-              (dolist (tf trusted-files)
+              (dolist (tf trusted-content)
                 (when (or (if exists (file-equal-p tf file) (equal tf file))
                           ;; We don't use `file-in-directory-p' here, because
                           ;; we want to err on the conservative side: "guilty
index e583e0fe32ce2f0901c4f5e3dc2e0668e2b7184d..7511d4b02ae871174f1fc36f4d8e28752cb9a018 100644 (file)
@@ -580,6 +580,7 @@ Customized bindings may be defined in `ielm-map', which currently contains:
        ielm-fontify-input-enable
        (comint-fontify-input-mode))
 
+  (setq-local trusted-content :all)
   (setq comint-prompt-regexp (concat "^" (regexp-quote ielm-prompt)))
   (setq-local paragraph-separate "\\'")
   (setq-local paragraph-start comint-prompt-regexp)
index 7674836a1a255da12ab8c8770cc01b03f59d5321..4003628dcb0437e49866e74e92868dce58a4fe9d 100644 (file)
@@ -567,8 +567,9 @@ use of `macroexpand-all' as a way to find the \"underlying raw code\".")
       (progn
         (when elisp--macroexpand-untrusted-warning
           (setq-local elisp--macroexpand-untrusted-warning nil) ;Don't spam!
-          (message "Completion of local vars is disabled in %s (untrusted content)"
-                   (buffer-name)))
+          (let ((inhibit-message t))      ;Only log.
+            (message "Completion of local vars is disabled in %s (untrusted content)"
+                     (buffer-name))))
         sexp)
     (let ((macroexpand-advice
            (lambda (expander form &rest args)
@@ -1330,7 +1331,8 @@ Semicolons start comments.
 
 \\{lisp-interaction-mode-map}"
   :abbrev-table nil
-  (setq-local lexical-binding t))
+  (setq-local lexical-binding t)
+  (setq-local trusted-content :all))
 
 ;;; Emacs Lisp Byte-Code mode
 
index af0f0664952d9c4bf63846b07f553032cbc16a18..142049ab25ff3e7464191bff98b5da67621dbe41 100644 (file)
@@ -2047,6 +2047,7 @@ function `read-from-minibuffer'."
                   #'elisp-completion-at-point nil t)
         (add-hook 'minibuffer-exit-hook
                   #'minibuffer-kill-completions-buffer nil t)
+        (setq-local trusted-content :all)
         (run-hooks 'eval-expression-minibuffer-setup-hook))
     (read-from-minibuffer prompt initial-contents
                           read--expression-map t