Function: trusted-content-p

trusted-content-p is a byte-compiled function defined in files.el.gz.

Signature

(trusted-content-p)

Documentation

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-content.

Source Code

;; Defined in /usr/src/emacs/lisp/files.el.gz
(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-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.
  (and (not untrusted-content)
       (or
        (eq trusted-content :all)
        (and
         buffer-file-truename
         (with-demoted-errors "trusted-content-p: %S"
           (let ((exists (file-exists-p buffer-file-truename)))
             (or
              ;; 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-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
                            ;; until proven innocent".
                            (and (string-suffix-p "/" tf)
                                 (string-prefix-p tf file)))
                    (setq trusted t)))
                trusted))))))))