>> Now, when desktop.el loads it, it asks if I want to apply the
>> font-lock-keywords customisation, because it is risky (is it?).
> Font-lock can modify arbitrary text properties, such as display
> strings, and not just faces.
And it can also directly run any code, which is even more immediately scary.
We should probably write a font-lock-keywords-safe-p. Something like the
one below, maybe.
Stefan
--- orig/lisp/font-lock.el
+++ mod/lisp/font-lock.el
@@ -454,6 +454,23 @@
user-level keywords, but normally their values have been
optimized.")
+(defun font-lock-keywords-safe-p (val)
+ (catch 'unsafe
+ (while (consp val)
+ (let ((kw (pop val)))
+ (unless (stringp (pop kw)) (throw 'unsafe nil))
+ (while (consp kw)
+ (let ((hl (pop kw)))
+ (unless (natnump (pop hl)) (throw 'unsafe nil))
+ (unless (or (symbolp (car hl))
+ (and (eq 'quote (safe-car (car hl)))
+ (symbolp (safe-car (cdar hl)))))
+ (throw 'unsafe nil))))
+ (when kw (throw 'unsafe nil))))
+ (when val (throw 'unsafe nil))
+ t))
+(put 'font-lock-keywords 'safe-local-variable 'font-lock-keywords-safe-p)
+
(defvar font-lock-keywords-alist nil
"Alist of additional `font-lock-keywords' elements for major modes.
_______________________________________________
emacs-pretest-bug mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug