[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-29 befa9fcaae2 03/11: org-macro--set-templates: Prevent code evalu
From: |
Eli Zaretskii |
Subject: |
emacs-29 befa9fcaae2 03/11: org-macro--set-templates: Prevent code evaluation |
Date: |
Sun, 24 Mar 2024 09:47:25 -0400 (EDT) |
branch: emacs-29
commit befa9fcaae29a6c9a283ba371c3c5234c7f644eb
Author: Ihor Radchenko <yantar92@posteo.net>
Commit: Eli Zaretskii <eliz@gnu.org>
org-macro--set-templates: Prevent code evaluation
* lisp/org/org-macro.el (org-macro--set-templates): Get rid of any
risk to evaluate code when `org-macro--set-templates' is called as a
part of major mode initialization. This way, no code evaluation is
ever triggered when user merely opens the file or when
`mm-display-org-inline' invokes Org major mode to fontify mime part
preview in email messages.
---
lisp/org/org-macro.el | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/lisp/org/org-macro.el b/lisp/org/org-macro.el
index 776d162be12..0be51eec512 100644
--- a/lisp/org/org-macro.el
+++ b/lisp/org/org-macro.el
@@ -109,6 +109,13 @@ previous one, unless VALUE is nil. Return the updated
list."
(let ((new-templates nil))
(pcase-dolist (`(,name . ,value) templates)
(let ((old-definition (assoc name new-templates)))
+ ;; This code can be evaluated unconditionally, as a part of
+ ;; loading Org mode. We *must not* evaluate any code present
+ ;; inside the Org buffer while loading. Org buffers may come
+ ;; from various sources, like received email messages from
+ ;; potentially malicious senders. Org mode might be used to
+ ;; preview such messages and no code evaluation from inside the
+ ;; received Org text should ever happen without user consent.
(when (and (stringp value) (string-match-p "\\`(eval\\>" value))
;; Pre-process the evaluation form for faster macro expansion.
(let* ((args (org-macro--makeargs value))
@@ -121,7 +128,7 @@ previous one, unless VALUE is nil. Return the updated
list."
(cadr (read value))
(error
(user-error "Invalid definition for macro %S" name)))))
- (setq value (eval (macroexpand-all `(lambda ,args ,body)) t))))
+ (setq value `(lambda ,args ,body))))
(cond ((and value old-definition) (setcdr old-definition value))
(old-definition)
(t (push (cons name (or value "")) new-templates)))))
- emacs-29 updated (e95a8622263 -> ae8f815613c), Eli Zaretskii, 2024/03/24
- emacs-29 3221d8d4611 02/11: * admin/authors.el (authors-aliases): Add ignored authors., Eli Zaretskii, 2024/03/24
- emacs-29 937b9042ad7 05/11: * lisp/gnus/mm-view.el (mm-display-inline-fontify): Mark contents untrusted., Eli Zaretskii, 2024/03/24
- emacs-29 befa9fcaae2 03/11: org-macro--set-templates: Prevent code evaluation,
Eli Zaretskii <=
- emacs-29 0dab0c0d688 09/11: Bump Emacs version to 29.3, Eli Zaretskii, 2024/03/24
- emacs-29 2bc865ace05 07/11: org-file-contents: Consider all remote files unsafe, Eli Zaretskii, 2024/03/24
- emacs-29 ccc188fcf98 04/11: * lisp/files.el (untrusted-content): New variable., Eli Zaretskii, 2024/03/24
- emacs-29 6f9ea396f49 06/11: org-latex-preview: Add protection when `untrusted-content' is non-nil, Eli Zaretskii, 2024/03/24
- emacs-29 ff6cc3d2cf0 10/11: * lisp/ldefs-boot.el: Regenerate., Eli Zaretskii, 2024/03/24
- emacs-29 7a5d7be52c5 08/11: org--confirm-resource-safe: Fix prompt when prompting in non-file Org buffers, Eli Zaretskii, 2024/03/24
- emacs-29 8d8253f8991 01/11: * etc/NEWS: Update for Emacs 29.3, Eli Zaretskii, 2024/03/24
- emacs-29 ae8f815613c 11/11: Update files for Emacs 29.3, Eli Zaretskii, 2024/03/24