From: Stefan Kangas Date: Sun, 26 Jan 2025 13:53:49 +0000 (+0100) Subject: Do not set `trusted-content` in major modes X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=cd5dd1831c726925d215483a83a3a3f56eb785e1;p=emacs.git Do not set `trusted-content` in major modes * lisp/progmodes/elisp-mode.el (lisp-interaction-mode): * lisp/ielm.el (inferior-emacs-lisp-mode): Do not set `trusted-content. * lisp/ielm.el (ielm): * lisp/simple.el (get-scratch-buffer-create): Set `trusted-content` here instead. * lisp/files.el (trusted-content): Doc fix; warn against setting this option to :all in a major or mode mode. Problem reported by Max Nikulin . (cherry picked from commit 5485ea6aef91c65a0ce300347db3c0ac138ad550) --- diff --git a/lisp/files.el b/lisp/files.el index 1a1898332b6..f27c4f41ddf 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -720,11 +720,12 @@ enabled (for example, when it is added to a mode hook). Each element of the list should be a string: - If it ends in \"/\", it is considered as a directory name and means that Emacs should trust all the files whose name has this directory as a prefix. -- else it is considered as a file name. +- Otherwise, it is considered a file name. Use abbreviated file names. For example, an entry \"~/mycode/\" means that Emacs will trust all the files in your directory \"mycode\". This variable can also be set to `:all', in which case Emacs will trust -all files, which opens a gaping security hole." +all files, which opens a gaping security hole. Emacs Lisp authors +should note that this value must never be set by a major or minor mode." :type '(choice (repeat :tag "List" file) (const :tag "Trust everything (DANGEROUS!)" :all)) :version "30.1") diff --git a/lisp/ielm.el b/lisp/ielm.el index 561185a738a..b3cd02b4dc0 100644 --- a/lisp/ielm.el +++ b/lisp/ielm.el @@ -580,7 +580,6 @@ 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) @@ -684,7 +683,8 @@ See `inferior-emacs-lisp-mode' for details." (unless (comint-check-proc buf-name) (with-current-buffer (get-buffer-create buf-name) (unless (zerop (buffer-size)) (setq old-point (point))) - (inferior-emacs-lisp-mode))) + (inferior-emacs-lisp-mode) + (setq-local trusted-content :all))) (pop-to-buffer-same-window buf-name) (when old-point (push-mark old-point)))) diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el index 7d0dd1b60dd..fe0cee2b565 100644 --- a/lisp/progmodes/elisp-mode.el +++ b/lisp/progmodes/elisp-mode.el @@ -1496,8 +1496,7 @@ Semicolons start comments. \\{lisp-interaction-mode-map}" :abbrev-table nil - (setq-local lexical-binding t) - (setq-local trusted-content :all)) + (setq-local lexical-binding t)) ;;; Emacs Lisp Byte-Code mode diff --git a/lisp/simple.el b/lisp/simple.el index 71bde1d098a..13319f8fa37 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -10935,7 +10935,9 @@ too short to have a dst element. (when initial-scratch-message (insert (substitute-command-keys initial-scratch-message)) (set-buffer-modified-p nil)) - (funcall initial-major-mode)) + (funcall initial-major-mode) + (when (eq initial-major-mode 'lisp-interaction-mode) + (setq-local trusted-content :all))) scratch))) (defun scratch-buffer ()