From 067dc590bb1c26c881f14d218da2cd502413ec5d Mon Sep 17 00:00:00 2001 From: Max Nikulin Date: Wed, 27 Mar 2024 23:04:07 +0700 Subject: [PATCH 1/2] org-ctags.el: Protect shell specials in directory name * lisp/org-ctags.el (org-ctags-create-tags): Escape shell specials. Directory name (the argument or `default-directory') may contain various characters interpreted by shell. Effects may vary from just incorrect actual path to execution of a command embedded into path. Neither double nor single quotes is a safe way to use directory name in shell commands since the name may contain these characters. A follow-up to Martin Marshall. [PATCH] `org-ctags-create-tags` creates empty TAGS file. Fri, 09 Feb 2024 18:57:48 -0500. --- lisp/org-ctags.el | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lisp/org-ctags.el b/lisp/org-ctags.el index 6431a2765..52b21dbd1 100644 --- a/lisp/org-ctags.el +++ b/lisp/org-ctags.el @@ -477,18 +477,21 @@ (defun org-ctags-create-tags (&optional directory-name) its subdirectories contain large numbers of taggable files." (interactive) (cl-assert (buffer-file-name)) - (let ((dir-name (or directory-name - (file-name-directory (buffer-file-name)))) + (let ((dir-name (shell-quote-argument + (expand-file-name + (if directory-name + (file-name-as-directory directory-name) + (file-name-directory (buffer-file-name)))))) (exitcode nil)) (save-excursion (setq exitcode (shell-command (format (concat "%s --langdef=orgmode --langmap=orgmode:.org " - "--regex-orgmode=\"%s\" -f \"%s\" -e -R %s") + "--regex-orgmode=%s -f %sTAGS -e -R %s*") org-ctags-path-to-ctags - org-ctags-tag-regexp - (expand-file-name (concat dir-name "/TAGS")) - (expand-file-name (concat (shell-quote-argument dir-name) "/*"))))) + (shell-quote-argument org-ctags-tag-regexp) + dir-name + dir-name))) (cond ((eql 0 exitcode) (setq-local org-ctags-tag-list -- 2.39.2