emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r101989: Use unsafep to check for the


From: Chong Yidong
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r101989: Use unsafep to check for theme safety.
Date: Mon, 18 Oct 2010 13:26:25 -0400
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 101989
committer: Chong Yidong <address@hidden>
branch nick: trunk
timestamp: Mon 2010-10-18 13:26:25 -0400
message:
  Use unsafep to check for theme safety.
  
  * cus-face.el (custom-theme-set-faces): Mark as a safe function.
  
  * custom.el (custom-theme-set-variables): Mark as a safe function.
  (load-theme): Check forms using unsafep.
modified:
  lisp/ChangeLog
  lisp/cus-face.el
  lisp/custom.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2010-10-18 16:01:43 +0000
+++ b/lisp/ChangeLog    2010-10-18 17:26:25 +0000
@@ -1,3 +1,10 @@
+2010-10-18  Chong Yidong  <address@hidden>
+
+       * custom.el (custom-theme-set-variables): Mark as a safe function.
+       (load-theme): Check forms using unsafep.
+
+       * cus-face.el (custom-theme-set-faces): Mark as a safe function.
+
 2010-10-17  Agustín Martín  <address@hidden>
 
        * textmodes/ispell.el (ispell-aspell-find-dictionary): Fix

=== modified file 'lisp/cus-face.el'
--- a/lisp/cus-face.el  2010-10-14 05:57:58 +0000
+++ b/lisp/cus-face.el  2010-10-18 17:26:25 +0000
@@ -349,6 +349,8 @@
              (put face 'face-override-spec nil)
              (face-spec-set face spec t))))))))
 
+(put 'custom-theme-set-faces 'safe-function t)
+
 ;; XEmacs compability function.  In XEmacs, when you reset a Custom
 ;; Theme, you have to specify the theme to reset it to.  We just apply
 ;; the next theme.

=== modified file 'lisp/custom.el'
--- a/lisp/custom.el    2010-10-17 00:00:34 +0000
+++ b/lisp/custom.el    2010-10-18 17:26:25 +0000
@@ -993,6 +993,8 @@
          (and (or now (default-boundp symbol))
               (put symbol 'variable-comment comment)))))))
 
+(put 'custom-theme-set-variables 'safe-function t)
+
 
 ;;; Defining themes.
 
@@ -1134,32 +1136,27 @@
     (with-temp-buffer
       (insert-file-contents fn)
       (let ((custom--inhibit-theme-enable no-enable)
-           sexp scar)
-       (while (setq sexp (let ((read-circle nil))
+           form scar)
+       (while (setq form (let ((read-circle nil))
                            (condition-case nil
                                (read (current-buffer))
                              (end-of-file nil))))
-         ;; Perform some checks on each sexp before evaluating it.
          (cond
-          ((not (listp sexp)))
-          ((eq (setq scar (car sexp)) 'deftheme)
-           (unless (eq (cadr sexp) theme)
+          ;; Check `deftheme' expressions.
+          ((eq (setq scar (car form)) 'deftheme)
+           (unless (eq (cadr form) theme)
              (error "Incorrect theme name in `deftheme'"))
-           (and (symbolp (nth 1 sexp))
-                (stringp (nth 2 sexp))
-                (eval (list scar (nth 1 sexp) (nth 2 sexp)))))
-          ((or (eq scar 'custom-theme-set-variables)
-               (eq scar 'custom-theme-set-faces))
-           (unless (equal (nth 1 sexp) `(quote ,theme))
-             (error "Incorrect theme name in theme settings"))
-           (dolist (entry (cddr sexp))
-             (unless (eq (car-safe entry) 'quote)
-               (error "Unsafe expression in theme settings")))
-           (eval sexp))
+           (and (symbolp (nth 1 form))
+                (stringp (nth 2 form))
+                (eval (list scar (nth 1 form) (nth 2 form)))))
+          ;; Check `provide-theme' expressions.
           ((and (eq scar 'provide-theme)
-                (equal (cadr sexp) `(quote ,theme))
-                (= (length sexp) 2))
-           (eval sexp))))))))
+                (equal (cadr form) `(quote ,theme))
+                (= (length form) 2))
+           (eval form))
+          ;; All other expressions need to be safe.
+          ((not (unsafep form))
+           (eval form))))))))
 
 (defun custom-theme-name-valid-p (name)
   "Return t if NAME is a valid name for a Custom theme, nil otherwise.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]