[PATCH] Set 'untrusted-content' to t in all modes

Subject: [PATCH] Set 'untrusted-content' to t in all modes

Date: Wed, 12 Mar 2025 06:36:21 -0300

To: notmuch@notmuchmail.org

Cc:

From: David Bremner


From: Stefan Kangas <stefankangas@gmail.com>

Instead of trying to guess in which modes this is safe not to set in,
let's just set it in all of them.

Background (added by db):

untrusted-content was added in Emacs 29.3 and is currently set by Gnus
and used by org-mode to prevent certain unsafe operations. I think the
intent is to use it for blocking more unsafe operations in the future.
---
 emacs/notmuch-hello.el | 4 +++-
 emacs/notmuch-mua.el   | 4 +++-
 emacs/notmuch-show.el  | 2 ++
 emacs/notmuch-tree.el  | 2 ++
 emacs/notmuch.el       | 2 ++
 5 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 15ba7c78..67c805a8 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -760,7 +760,9 @@ The screen may be customized via `\\[customize]'.
 Complete list of currently available key bindings:
 
 \\{notmuch-hello-mode-map}"
-  (setq notmuch-buffer-refresh-function #'notmuch-hello-update))
+  (setq notmuch-buffer-refresh-function #'notmuch-hello-update)
+  (when (boundp 'untrusted-content)
+    (setq untrusted-content t)))
 
 ;;; Inserters
 
diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index a75b0f5c..74c62aaf 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -379,7 +379,9 @@ Typically this is added to `notmuch-mua-send-hook'."
 
 (define-derived-mode notmuch-message-mode message-mode "Message[Notmuch]"
   "Notmuch message composition mode. Mostly like `message-mode'."
-  (notmuch-address-setup))
+  (notmuch-address-setup)
+  (when (boundp 'untrusted-content)
+    (setq untrusted-content t)))
 
 (put 'notmuch-message-mode 'flyspell-mode-predicate 'mail-mode-flyspell-verify)
 
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 921c0ef1..8a8e6a7b 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1696,6 +1696,8 @@ All currently available key bindings:
   (setq notmuch-buffer-refresh-function #'notmuch-show-refresh-view)
   (setq buffer-read-only t)
   (setq truncate-lines t)
+  (when (boundp 'untrusted-content)
+    (setq untrusted-content t))
   (setq imenu-prev-index-position-function
 	#'notmuch-show-imenu-prev-index-position-function)
   (setq imenu-extract-index-name-function
diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 2332f020..6ff0567b 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -1094,6 +1094,8 @@ Complete list of currently available key bindings:
   (hl-line-mode 1)
   (setq buffer-read-only t)
   (setq truncate-lines t)
+  (when (boundp 'untrusted-content)
+    (setq untrusted-content t))
   (when notmuch-tree-outline-enabled (notmuch-tree-outline-mode 1)))
 
 (defvar notmuch-tree-process-exit-functions nil
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 2a73ffa5..60e3d314 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -412,6 +412,8 @@ Complete list of currently available key bindings:
   (add-to-invisibility-spec (cons 'ellipsis t))
   (setq truncate-lines t)
   (setq buffer-read-only t)
+  (when (boundp 'untrusted-content)
+    (setq untrusted-content t))
   (setq imenu-prev-index-position-function
 	#'notmuch-search-imenu-prev-index-position-function)
   (setq imenu-extract-index-name-function
-- 
2.47.2

_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: