org-file-contents: Consider all remote files unsafe

* lisp/org.el (org-file-contents): When loading files, consider all
remote files (like TRAMP-fetched files) unsafe, in addition to URLs.
This commit is contained in:
Ihor Radchenko 2024-02-20 14:59:20 +03:00
parent 03635a3355
commit 4255d5dcc0
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 5 additions and 1 deletions

View File

@ -4572,12 +4572,16 @@ from file or URL, and return nil.
If NOCACHE is non-nil, do a fresh fetch of FILE even if cached version If NOCACHE is non-nil, do a fresh fetch of FILE even if cached version
is available. This option applies only if FILE is a URL." is available. This option applies only if FILE is a URL."
(let* ((is-url (org-url-p file)) (let* ((is-url (org-url-p file))
(is-remote (condition-case nil
(file-remote-p file)
;; In case of error, be safe.
(t t)))
(cache (and is-url (cache (and is-url
(not nocache) (not nocache)
(gethash file org--file-cache)))) (gethash file org--file-cache))))
(cond (cond
(cache) (cache)
(is-url ((or is-url is-remote)
(if (org--should-fetch-remote-resource-p file) (if (org--should-fetch-remote-resource-p file)
(condition-case error (condition-case error
(with-current-buffer (url-retrieve-synchronously file) (with-current-buffer (url-retrieve-synchronously file)