diff options
| author | Vitaliy Chepelev | 2024-09-24 04:25:13 +0000 |
|---|---|---|
| committer | Stefan Kangas | 2025-03-04 10:58:41 +0100 |
| commit | d6288eeb429e8e5774b3b248fd62bb4549779b67 (patch) | |
| tree | c2bd78694e99041e6ef2e6b816666e61b6e627e9 | |
| parent | 1b80bc67aadd01de00b7911ae32bf5d91b262a8a (diff) | |
| download | emacs-d6288eeb429e8e5774b3b248fd62bb4549779b67.tar.gz emacs-d6288eeb429e8e5774b3b248fd62bb4549779b67.zip | |
image-dired: Don't croak on file names with regexp characters
* lisp/image/image-dired-dired.el (image-dired-mark-tagged-files):
* lisp/image/image-dired-tags.el (image-dired-get-comment)
(image-dired-write-comments, image-dired-list-tags)
(image-dired-remove-tag, image-dired-write-tags): Quote file name
for search-forward-regexp. (Bug#73445)
Copyright-paperwork-exempt: yes
(cherry picked from commit 7930fe2f44f50b6a7abf5fbe1218dcc15e85b28d)
| -rw-r--r-- | lisp/image/image-dired-dired.el | 2 | ||||
| -rw-r--r-- | lisp/image/image-dired-tags.el | 10 |
2 files changed, 6 insertions, 6 deletions
diff --git a/lisp/image/image-dired-dired.el b/lisp/image/image-dired-dired.el index 8b68a5c069b..c7994cd4096 100644 --- a/lisp/image/image-dired-dired.el +++ b/lisp/image/image-dired-dired.el | |||
| @@ -383,7 +383,7 @@ matching tag will be marked in the Dired buffer." | |||
| 383 | (file-name-directory curr-file))) | 383 | (file-name-directory curr-file))) |
| 384 | (setq curr-file (file-name-nondirectory curr-file)) | 384 | (setq curr-file (file-name-nondirectory curr-file)) |
| 385 | (goto-char (point-min)) | 385 | (goto-char (point-min)) |
| 386 | (when (search-forward-regexp (format "\\s %s[*@]?$" curr-file) nil t) | 386 | (when (search-forward-regexp (format "\\s %s[*@]?$" (regexp-quote curr-file)) nil t) |
| 387 | (setq hits (+ hits 1)) | 387 | (setq hits (+ hits 1)) |
| 388 | (dired-mark 1)))) | 388 | (dired-mark 1)))) |
| 389 | (message "%d files with matching tag marked" hits))) | 389 | (message "%d files with matching tag marked" hits))) |
diff --git a/lisp/image/image-dired-tags.el b/lisp/image/image-dired-tags.el index 8be2bfe4218..eccab48e0fe 100644 --- a/lisp/image/image-dired-tags.el +++ b/lisp/image/image-dired-tags.el | |||
| @@ -79,7 +79,7 @@ FILE-TAGS is an alist in the following form: | |||
| 79 | (setq file (car elt) | 79 | (setq file (car elt) |
| 80 | tag (cdr elt)) | 80 | tag (cdr elt)) |
| 81 | (goto-char (point-min)) | 81 | (goto-char (point-min)) |
| 82 | (if (search-forward-regexp (format "^%s.*$" file) nil t) | 82 | (if (search-forward-regexp (format "^%s.*$" (regexp-quote file)) nil t) |
| 83 | (progn | 83 | (progn |
| 84 | (setq end (point)) | 84 | (setq end (point)) |
| 85 | (beginning-of-line) | 85 | (beginning-of-line) |
| @@ -103,7 +103,7 @@ FILES can be a name of a single file (a string) or a list of file names." | |||
| 103 | (error "Files must be a string or a list of strings!"))) | 103 | (error "Files must be a string or a list of strings!"))) |
| 104 | (dolist (file files) | 104 | (dolist (file files) |
| 105 | (goto-char (point-min)) | 105 | (goto-char (point-min)) |
| 106 | (when (search-forward-regexp (format "^%s;" file) nil t) | 106 | (when (search-forward-regexp (format "^%s;" (regexp-quote file)) nil t) |
| 107 | (end-of-line) | 107 | (end-of-line) |
| 108 | (setq end (point)) | 108 | (setq end (point)) |
| 109 | (beginning-of-line) | 109 | (beginning-of-line) |
| @@ -125,7 +125,7 @@ Value is a list of all tags for FILE." | |||
| 125 | (image-dired-sane-db-file) | 125 | (image-dired-sane-db-file) |
| 126 | (image-dired--with-db-file | 126 | (image-dired--with-db-file |
| 127 | (let (end (tags "")) | 127 | (let (end (tags "")) |
| 128 | (when (search-forward-regexp (format "^%s" file) nil t) | 128 | (when (search-forward-regexp (format "^%s" (regexp-quote file)) nil t) |
| 129 | (end-of-line) | 129 | (end-of-line) |
| 130 | (setq end (point)) | 130 | (setq end (point)) |
| 131 | (beginning-of-line) | 131 | (beginning-of-line) |
| @@ -179,7 +179,7 @@ FILE-COMMENTS is an alist on the following form: | |||
| 179 | (setq file (car elt) | 179 | (setq file (car elt) |
| 180 | comment (cdr elt)) | 180 | comment (cdr elt)) |
| 181 | (goto-char (point-min)) | 181 | (goto-char (point-min)) |
| 182 | (if (search-forward-regexp (format "^%s.*$" file) nil t) | 182 | (if (search-forward-regexp (format "^%s.*$" (regexp-quote file)) nil t) |
| 183 | (progn | 183 | (progn |
| 184 | (setq end (point)) | 184 | (setq end (point)) |
| 185 | (beginning-of-line) | 185 | (beginning-of-line) |
| @@ -236,7 +236,7 @@ Optionally use old comment from FILE as initial value." | |||
| 236 | (image-dired-sane-db-file) | 236 | (image-dired-sane-db-file) |
| 237 | (image-dired--with-db-file | 237 | (image-dired--with-db-file |
| 238 | (let (end comment-beg-pos comment-end-pos comment) | 238 | (let (end comment-beg-pos comment-end-pos comment) |
| 239 | (when (search-forward-regexp (format "^%s" file) nil t) | 239 | (when (search-forward-regexp (format "^%s" (regexp-quote file)) nil t) |
| 240 | (end-of-line) | 240 | (end-of-line) |
| 241 | (setq end (point)) | 241 | (setq end (point)) |
| 242 | (beginning-of-line) | 242 | (beginning-of-line) |