diff options
| author | Richard M. Stallman | 2002-10-23 17:38:44 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2002-10-23 17:38:44 +0000 |
| commit | 472514b72d9aa1db35fde6670c8be6eb957590a4 (patch) | |
| tree | 0ee119a7d5f61684779a2fdbdd79a666770993ac | |
| parent | e99833cab6c4098a4916af3d7beefad59ceb4012 (diff) | |
| download | emacs-472514b72d9aa1db35fde6670c8be6eb957590a4.tar.gz emacs-472514b72d9aa1db35fde6670c8be6eb957590a4.zip | |
(risky-local-variable-p): New function.
(compile-command): Use `stringp' for `safe-local-variable' prop.
(hack-one-local-variable): Use `risky-local-variable-p'.
| -rw-r--r-- | lisp/files.el | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/lisp/files.el b/lisp/files.el index 9da9bd87875..be6cdfeb9b7 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -2057,16 +2057,21 @@ is specified, returning t if it is specified." | |||
| 2057 | (put 'mode-line-position 'risky-local-variable t) | 2057 | (put 'mode-line-position 'risky-local-variable t) |
| 2058 | (put 'display-time-string 'risky-local-variable t) | 2058 | (put 'display-time-string 'risky-local-variable t) |
| 2059 | 2059 | ||
| 2060 | ;; This one is safe because the user gets to check it before it is used. | 2060 | ;; This case is safe because the user gets to check it before it is used. |
| 2061 | (put 'compile-command 'safe-local-variable t) | 2061 | (put 'compile-command 'safe-local-variable 'stringp) |
| 2062 | 2062 | ||
| 2063 | (defun risky-local-variable-p (sym) | 2063 | (defun risky-local-variable-p (sym val) |
| 2064 | "Returns non-nil if SYM could be dangerous as a file-local variable." | 2064 | "Non-nil if SYM could be dangerous as a file-local variable with value VAL." |
| 2065 | (or (memq sym ignored-local-variables) | 2065 | (let ((safep (get sym 'safe-local-variable))) |
| 2066 | (get sym 'risky-local-variable) | 2066 | (or (memq sym ignored-local-variables) |
| 2067 | (and (string-match "-hooks?$\\|-functions?$\\|-forms?$\\|-program$\\|-command$\\|-predicate$\\|font-lock-keywords$\\|font-lock-keywords-[0-9]+$\\|font-lock-syntactic-keywords$\\|-frame-alist$\\|-mode-alist$\\|-map$\\|-map-alist$" | 2067 | (get sym 'risky-local-variable) |
| 2068 | (symbol-name sym)) | 2068 | (and (string-match "-hooks?$\\|-functions?$\\|-forms?$\\|-program$\\|-command$\\|-predicate$\\|font-lock-keywords$\\|font-lock-keywords-[0-9]+$\\|font-lock-syntactic-keywords$\\|-frame-alist$\\|-mode-alist$\\|-map$\\|-map-alist$" |
| 2069 | (not (get sym 'safe-local-variable))))) | 2069 | (symbol-name sym)) |
| 2070 | (not safep)) | ||
| 2071 | ;; If the safe-local-variable property isn't t or nil, | ||
| 2072 | ;; then it must return non-nil on the proposed value to be safe. | ||
| 2073 | (and (not (memq safep '(t nil))) | ||
| 2074 | (not (funcall safep val)))))) | ||
| 2070 | 2075 | ||
| 2071 | (defcustom safe-local-eval-forms nil | 2076 | (defcustom safe-local-eval-forms nil |
| 2072 | "*Expressions that are considered \"safe\" in an `eval:' local variable. | 2077 | "*Expressions that are considered \"safe\" in an `eval:' local variable. |
| @@ -2134,7 +2139,7 @@ is considered risky." | |||
| 2134 | nil) | 2139 | nil) |
| 2135 | ;; "Setting" eval means either eval it or do nothing. | 2140 | ;; "Setting" eval means either eval it or do nothing. |
| 2136 | ;; Likewise for setting hook variables. | 2141 | ;; Likewise for setting hook variables. |
| 2137 | ((risky-local-variable-p var) | 2142 | ((risky-local-variable-p var val) |
| 2138 | ;; Permit evalling a put of a harmless property. | 2143 | ;; Permit evalling a put of a harmless property. |
| 2139 | ;; if the args do nothing tricky. | 2144 | ;; if the args do nothing tricky. |
| 2140 | (if (or (and (eq var 'eval) | 2145 | (if (or (and (eq var 'eval) |
| @@ -2157,7 +2162,7 @@ is considered risky." | |||
| 2157 | (save-excursion (eval val)) | 2162 | (save-excursion (eval val)) |
| 2158 | (make-local-variable var) | 2163 | (make-local-variable var) |
| 2159 | (set var val)) | 2164 | (set var val)) |
| 2160 | (message "Ignoring `eval:' in the local variables list"))) | 2165 | (message "Ignoring risky spec in the local variables list"))) |
| 2161 | ;; Ordinary variable, really set it. | 2166 | ;; Ordinary variable, really set it. |
| 2162 | (t (make-local-variable var) | 2167 | (t (make-local-variable var) |
| 2163 | ;; Make sure the string has no text properties. | 2168 | ;; Make sure the string has no text properties. |