all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Stuart D. Herring" <herring@lanl.gov>
Cc: emacs-devel@gnu.org
Subject: Re: turn off safe-local-variable-values checking
Date: Wed, 12 Apr 2006 12:57:44 -0700 (PDT)	[thread overview]
Message-ID: <41361.128.165.123.132.1144871864.squirrel@webmail.lanl.gov> (raw)
In-Reply-To: <E1FT155-0006oT-Qn@fencepost.gnu.org>

[-- Attachment #1: Type: text/plain, Size: 805 bytes --]

>     table.el
>     allout.el
>     ediff*.el
>
> This is useful--I presume these bindings are safe,
> so we should define predicates for the variables they bind.
>
> Would someone like to do that now, and ack?

Interesting: each of those three files required a different approach.  I
added predicates for time-stamp.el's local variables, putting reasonable
limits on the integers.  Allout just needed to autoload its
already-present safe-local declaration.  And ediff was using part of
edebug which could really be used for evil, so I wrote a check for
non-evil use and added that to the code for symbol properties.

Patch attached, natch.

Davis

-- 
This product is sold by volume, not by mass.  If it appears too dense or
too sparse, it is because mass-energy conversion has occurred during
shipping.

[-- Attachment #2: local-variables.patch --]
[-- Type: application/octet-stream, Size: 6711 bytes --]

? local-variables.patch
Index: lisp/ChangeLog
===================================================================
RCS file: /sources/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.9390
diff -a -c -r1.9390 ChangeLog
*** lisp/ChangeLog	12 Apr 2006 05:11:12 -0000	1.9390
--- lisp/ChangeLog	12 Apr 2006 19:55:17 -0000
***************
*** 1,3 ****
--- 1,18 ----
+ 2006-04-12  Davis Herring  <herring@lanl.gov>
+ 
+ 	* files.el: Add predicates for time-stamp.el's file-local
+ 	variables (here, since it's never automatically loaded).  Remove
+ 	lingering `string-or-null' let-binding.
+ 	(hack-one-local-variable-eval-safep): Recognize
+ 	`edebug-form-spec' for `put', but only if it passes
+ 	`edebug-basic-spec'.  Generalize `put' handling.
+ 
+ 	* emacs-lisp/edebug.el (edebug-basic-spec): New function for
+ 	vetting file-local form specs.
+ 
+ 	* allout.el (allout-layout): Autoload its `safe-local-variable'
+ 	property.
+ 
  2006-04-12  Stefan Monnier  <monnier@iro.umontreal.ca>
  
  	* progmodes/perl-mode.el (perl-indent-new-calculate):
Index: lisp/allout.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/allout.el,v
retrieving revision 1.70
diff -a -c -r1.70 allout.el
*** lisp/allout.el	15 Mar 2006 03:14:15 -0000	1.70
--- lisp/allout.el	12 Apr 2006 19:55:18 -0000
***************
*** 666,671 ****
--- 666,672 ----
  `allout-layout' can additionally have the value `t', in which
  case the value of `allout-default-layout' is used.")
  (make-variable-buffer-local 'allout-layout)
+ ;;;###autoload
  (put 'allout-layout 'safe-local-variable t)
  
  ;;;_  : Topic header format
Index: lisp/files.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/files.el,v
retrieving revision 1.825
diff -a -c -r1.825 files.el
*** lisp/files.el	11 Apr 2006 17:57:34 -0000	1.825
--- lisp/files.el	12 Apr 2006 19:55:18 -0000
***************
*** 2343,2371 ****
  ;; For variables defined in the C source code the declaration should go here:
  
  ;; FIXME: Some variables should be moved according to the rules above.
! (let ((string-or-null (lambda (a) (or (stringp a) (null a)))))
!   (eval
!    `(mapc (lambda (pair)
! 	    (put (car pair) 'safe-local-variable (cdr pair)))
! 	  '((byte-compile-dynamic . t)
! 	    (byte-compile-dynamic-docstrings . t)
! 	    (byte-compile-warnings . t)
! 	    (c-basic-offset     .  integerp)
! 	    (c-file-style       .  stringp)
! 	    (c-indent-level     .  integerp)
! 	    (comment-column     .  integerp)
! 	    (compile-command    .  string-or-null-p)
! 	    (fill-column        .  integerp)
! 	    (fill-prefix        .  string-or-null-p)
! 	    (indent-tabs-mode   .  t)
! 	    (kept-new-versions  .  integerp)
! 	    (left-margin        .  t)
! 	    (no-byte-compile    .  t)
! 	    (no-update-autoloads . t)
! 	    (outline-regexp     .  string-or-null-p)
! 	    (tab-width          .  integerp) ;; C source code
! 	    (truncate-lines     .  t) ;; C source code
! 	    (version-control    .  t)))))
  
  (put 'c-set-style 'safe-local-eval-function t)
  
--- 2343,2380 ----
  ;; For variables defined in the C source code the declaration should go here:
  
  ;; FIXME: Some variables should be moved according to the rules above.
! (eval
!  `(mapc (lambda (pair)
! 	  (put (car pair) 'safe-local-variable (cdr pair)))
! 	'((byte-compile-dynamic . t)
! 	  (byte-compile-dynamic-docstrings . t)
! 	  (byte-compile-warnings . t)
! 	  (c-basic-offset     .  integerp)
! 	  (c-file-style       .  stringp)
! 	  (c-indent-level     .  integerp)
! 	  (comment-column     .  integerp)
! 	  (compile-command    .  string-or-null-p)
! 	  (fill-column        .  integerp)
! 	  (fill-prefix        .  string-or-null-p)
! 	  (indent-tabs-mode   .  t)
! 	  (kept-new-versions  .  integerp)
! 	  (left-margin        .  t)
! 	  (no-byte-compile    .  t)
! 	  (no-update-autoloads . t)
! 	  (outline-regexp     .  string-or-null-p)
! 	  (tab-width          .  integerp) ;; C source code
! 	  (time-stamp-inserts-lines . t)
! 	  (time-stamp-line-limit . (lambda (val) (and (integerp val)
! 						      (not (zerop val))
! 						      (<= (abs val) 1000))))
! 	  (time-stamp-count   .  (lambda (val) (and (integerp val)
! 						    (<= val 100))))
! 	  (time-stamp-end     .  stringp)
! 	  (time-stamp-format  .  stringp)
! 	  (time-stamp-pattern .  string-or-null-p)
! 	  (time-stamp-start   .  stringp)
! 	  (truncate-lines     .  t) ;; C source code
! 	  (version-control    .  t))))
  
  (put 'c-set-style 'safe-local-eval-function t)
  
***************
*** 2689,2700 ****
        (and (eq (car exp) 'put)
  	   (hack-one-local-variable-quotep (nth 1 exp))
  	   (hack-one-local-variable-quotep (nth 2 exp))
! 	   (memq (nth 1 (nth 2 exp))
! 		 '(lisp-indent-hook))
! 	   ;; Only allow safe values of lisp-indent-hook;
! 	   ;; not functions.
! 	   (or (numberp (nth 3 exp))
! 	       (equal (nth 3 exp) ''defun)))
        ;; Allow expressions that the user requested.
        (member exp safe-local-eval-forms)
        ;; Certain functions can be allowed with safe arguments
--- 2698,2711 ----
        (and (eq (car exp) 'put)
  	   (hack-one-local-variable-quotep (nth 1 exp))
  	   (hack-one-local-variable-quotep (nth 2 exp))
! 	   (let ((prop (nth 1 (nth 2 exp))) (val (nth 3 exp)))
! 	     (cond ((eq prop 'lisp-indent-hook)
! 		    ;; Only allow safe values of lisp-indent-hook;
! 		    ;; not functions.
! 		    (or (numberp val) (equal val ''defun)))
! 		   ((eq prop 'edebug-form-spec)
! 		    ;; Only allow indirect form specs.
! 		    (edebug-basic-spec val)))))
        ;; Allow expressions that the user requested.
        (member exp safe-local-eval-forms)
        ;; Certain functions can be allowed with safe arguments
Index: lisp/emacs-lisp/edebug.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/emacs-lisp/edebug.el,v
retrieving revision 3.88
diff -a -c -r3.88 edebug.el
*** lisp/emacs-lisp/edebug.el	3 Mar 2006 11:55:43 -0000	3.88
--- lisp/emacs-lisp/edebug.el	12 Apr 2006 19:55:19 -0000
***************
*** 258,263 ****
--- 258,277 ----
      edebug-form-spec
      ))
  
+ ;;;###autoload
+ (defun edebug-basic-spec (spec)
+   "Return t if SPEC uses only extant spec symbols.
+ An extant spec symbol is a symbol that is not a function and has a
+ `edebug-form-spec' property."
+   (cond ((listp spec)
+ 	 (catch 'basic
+ 	   (while spec
+ 	     (unless (edebug-basic-spec (car spec)) (throw 'basic nil))
+ 	     (setq spec (cdr spec)))
+ 	   t))
+ 	((symbolp spec)
+ 	 (unless (functionp spec) (get spec 'edebug-form-spec)))))
+ 
  ;;; Utilities
  
  ;; Define edebug-gensym - from old cl.el

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

  parent reply	other threads:[~2006-04-12 19:57 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-30 11:27 turn off safe-local-variable-values checking Shug Boabby
2006-03-31 17:28 ` Richard Stallman
2006-03-31 20:58 ` Stefan Monnier
2006-04-03  0:12   ` Shug Boabby
2006-04-03  0:49     ` Dan Nicolaescu
2006-04-03  0:56       ` David Kastrup
2006-04-03  1:16         ` Dan Nicolaescu
2006-04-03  1:34           ` David Kastrup
2006-04-04 17:38             ` AUCTex (was: turn off safe-local-variable-values checking) Dan Nicolaescu
2006-04-04 21:12               ` AUCTex David Kastrup
2006-04-05 19:41                 ` AUCTex Dan Nicolaescu
2006-04-05 19:53                   ` AUCTex David Kastrup
2006-04-03  2:25     ` turn off safe-local-variable-values checking Stefan Monnier
2006-04-03  2:58       ` Johan Bockgård
2006-04-03 13:51         ` Richard Stallman
2006-04-10 18:25         ` Richard Stallman
2006-04-12 18:13           ` Stuart D. Herring
2006-04-13  3:20             ` Richard Stallman
2006-04-13 15:04               ` Stuart D. Herring
2006-04-16  2:09                 ` M-x normal-mode and local variables Richard Stallman
2006-04-16 12:22                   ` Stefan Monnier
2006-04-17 17:56                     ` Richard Stallman
2006-04-12 19:57           ` Stuart D. Herring [this message]
2007-03-01  0:58             ` turn off safe-local-variable-values checking Stuart D. Herring
2007-03-01 17:12               ` Chong Yidong
2007-03-01 20:12                 ` Stuart D. Herring
2006-04-03 14:44       ` Andreas Schwab
2006-04-03 23:57         ` Richard Stallman
2006-04-04 18:59           ` Andreas Schwab
2006-04-04 19:37           ` Reiner Steib
2006-04-04 20:46             ` Stefan Monnier
2006-04-05  8:19               ` Reiner Steib
2006-04-05 13:01                 ` Stefan Monnier
2006-04-05 15:51                   ` Chong Yidong
2006-04-06  1:11                   ` Richard Stallman
2006-04-06 15:40                     ` Additional safe-local-variables (was: turn off safe-local-variable-values checking) Reiner Steib
2006-04-06 17:51                       ` Richard Stallman
2006-04-06 19:23                         ` Additional safe-local-variables Reiner Steib
2006-04-07  2:19                           ` Richard Stallman
2006-04-07 18:55                             ` Reiner Steib
2006-04-08 16:17                               ` Richard Stallman
2006-04-05  1:51             ` turn off safe-local-variable-values checking Richard Stallman
2006-04-05  3:45               ` Miles Bader
2006-04-05 14:54                 ` Richard Stallman
2006-04-03  0:13   ` Shug Boabby

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=41361.128.165.123.132.1144871864.squirrel@webmail.lanl.gov \
    --to=herring@lanl.gov \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.