aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAntero Mejr2023-05-09 20:51:14 +0000
committerEli Zaretskii2023-05-11 16:33:16 +0300
commitf24ea84f430d5ae6fd3fa5373610551f62ce25be (patch)
tree47901040117df1160679509917493bf6825b9dc7 /test
parent44c2befb4a36391f17ee8f3539dee7be62df89f0 (diff)
downloademacs-f24ea84f430d5ae6fd3fa5373610551f62ce25be.tar.gz
emacs-f24ea84f430d5ae6fd3fa5373610551f62ce25be.zip
Add safe-local-variable-directories variable.
This variable can be set to automatically load risky dir-local variables from a list of trusted directories. * lisp/emacs-lisp/files.el (safe-local-variable-directories, hack-local-variables-filter, hack-local-variables-confirm): New variable and associated logic. * test/lisp/files-tests.el (files-tests-safe-local-variable-directories): Add tests for same. * doc/emacs/custom.texi (Safe File Variables): Add documentation for same. * doc/lispref/variables.texi (File Local Variables): Add documentation for same. * etc/NEWS (Lisp Changes in Emacs 30.1): Add news entry for same. (Bug#61901)
Diffstat (limited to 'test')
-rw-r--r--test/lisp/files-tests.el21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el
index aadb60e1de7..e87bb3cfa0a 100644
--- a/test/lisp/files-tests.el
+++ b/test/lisp/files-tests.el
@@ -166,6 +166,27 @@ form.")
166 (hack-local-variables) 166 (hack-local-variables)
167 (should (eq lexical-binding nil))))) 167 (should (eq lexical-binding nil)))))
168 168
169(ert-deftest files-tests-safe-local-variable-directories ()
170 ;; safe-local-variable-directories should be risky,
171 ;; so use it as an arbitrary risky variable.
172 (let ((test-alist '((safe-local-variable-directories . "some_val")))
173 (fakedir "/test1/test2/")
174 (enable-local-eval t))
175 (with-temp-buffer
176 (setq safe-local-variable-directories (list fakedir))
177 (hack-local-variables-filter test-alist fakedir)
178 (should (equal file-local-variables-alist test-alist)))
179 (with-temp-buffer
180 (setq safe-local-variable-directories (list fakedir))
181 (setq noninteractive t)
182 (hack-local-variables-filter test-alist "wrong")
183 (should-not (equal file-local-variables-alist test-alist)))
184 (with-temp-buffer
185 (setq safe-local-variable-directories '())
186 (setq noninteractive t)
187 (hack-local-variables-filter test-alist fakedir)
188 (should-not (equal file-local-variables-alist test-alist)))))
189
169(defvar files-test-bug-18141-file 190(defvar files-test-bug-18141-file
170 (ert-resource-file "files-bug18141.el.gz") 191 (ert-resource-file "files-bug18141.el.gz")
171 "Test file for bug#18141.") 192 "Test file for bug#18141.")