* lisp/files.el (trusted-content-p): Make :all work in non-file buffers

This commit is contained in:
Stefan Monnier 2024-12-16 09:27:01 -05:00
parent 4b685bc4fc
commit b9dc337ea7

View file

@ -742,11 +742,13 @@ See also `trusted-content'."
;; to try and avoid marking as trusted a file that's merely accessed ;; to try and avoid marking as trusted a file that's merely accessed
;; via a symlink that happens to be inside a trusted dir. ;; via a symlink that happens to be inside a trusted dir.
(and (not untrusted-content) (and (not untrusted-content)
(or
(eq trusted-content :all)
(and
buffer-file-truename buffer-file-truename
(with-demoted-errors "trusted-content-p: %S" (with-demoted-errors "trusted-content-p: %S"
(let ((exists (file-exists-p buffer-file-truename))) (let ((exists (file-exists-p buffer-file-truename)))
(or (or
(eq trusted-content :all)
;; We can't avoid trusting the user's init file. ;; We can't avoid trusting the user's init file.
(if (and exists user-init-file) (if (and exists user-init-file)
(file-equal-p buffer-file-truename user-init-file) (file-equal-p buffer-file-truename user-init-file)
@ -761,7 +763,7 @@ See also `trusted-content'."
(and (string-suffix-p "/" tf) (and (string-suffix-p "/" tf)
(string-prefix-p tf file))) (string-prefix-p tf file)))
(setq trusted t))) (setq trusted t)))
trusted)))))) trusted))))))))
;; This is an odd variable IMO. ;; This is an odd variable IMO.
;; You might wonder why it is needed, when we could just do: ;; You might wonder why it is needed, when we could just do: