aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXi Lu2023-01-07 22:46:40 +0800
committerEli Zaretskii2023-01-14 11:05:53 +0200
commit7100ecd7a472a5ff49d7c8a4b9c061a50520e93b (patch)
treed47d1dc9049af944e86bdfe53fcf14e689b57bf3
parentf102145d381f975e937dd4512a2ac53af604be4a (diff)
downloademacs-7100ecd7a472a5ff49d7c8a4b9c061a50520e93b.tar.gz
emacs-7100ecd7a472a5ff49d7c8a4b9c061a50520e93b.zip
Replace 'hfy-find-cmd' with 'directory-files-recursively'.
This removes a potential vulnerability to maliciously named files. (Bug#60562) * lisp/htmlfontify.el (hfy-exclude-file-rules): New defcustom. (hfy-list-files): Reimplement using 'directory-files-recursively'.
-rw-r--r--lisp/htmlfontify.el21
1 files changed, 14 insertions, 7 deletions
diff --git a/lisp/htmlfontify.el b/lisp/htmlfontify.el
index c989a12d205..f05bc4e1e35 100644
--- a/lisp/htmlfontify.el
+++ b/lisp/htmlfontify.el
@@ -372,11 +372,14 @@ otherwise."
372 :tag "istext-command" 372 :tag "istext-command"
373 :type '(string)) 373 :type '(string))
374 374
375(defcustom hfy-find-cmd 375(defcustom hfy-exclude-file-rules
376 "find . -type f \\! -name \\*~ \\! -name \\*.flc \\! -path \\*/CVS/\\*" 376 '("\\.flc$"
377 "Find command used to harvest a list of files to attempt to fontify." 377 "/CVS/.*"
378 :tag "find-command" 378 ".*~$"
379 :type '(string)) 379 "/\\.git\\(?:/.*\\)?$")
380 "Define some regular expressions to exclude files"
381 :tag "exclude-rules"
382 :type '(list string))
380 383
381(defcustom hfy-display-class nil 384(defcustom hfy-display-class nil
382 "Display class to use to determine which display class to use when 385 "Display class to use to determine which display class to use when
@@ -1826,8 +1829,12 @@ Strips any leading \"./\" from each filename."
1826 ;;(message "hfy-list-files");;DBUG 1829 ;;(message "hfy-list-files");;DBUG
1827 ;; FIXME: this changes the dir of the current buffer. Is that right?? 1830 ;; FIXME: this changes the dir of the current buffer. Is that right??
1828 (cd directory) 1831 (cd directory)
1829 (mapcar (lambda (F) (if (string-match "^./\\(.*\\)" F) (match-string 1 F) F)) 1832 (cl-remove-if (lambda (f)
1830 (split-string (shell-command-to-string hfy-find-cmd))) ) 1833 (or (null (file-regular-p f))
1834 (seq-some (lambda (r)
1835 (string-match r f))
1836 hfy-exclude-file-rules)))
1837 (directory-files-recursively "." ".*" nil t)))
1831 1838
1832;; strip the filename off, return a directory name 1839;; strip the filename off, return a directory name
1833;; not a particularly thorough implementation, but it will be 1840;; not a particularly thorough implementation, but it will be