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 7930fe2f44)
This commit is contained in:
Vitaliy Chepelev 2024-09-24 04:25:13 +00:00 committed by Stefan Kangas
parent 1b80bc67aa
commit d6288eeb42
2 changed files with 6 additions and 6 deletions

View file

@ -383,7 +383,7 @@ matching tag will be marked in the Dired buffer."
(file-name-directory curr-file)))
(setq curr-file (file-name-nondirectory curr-file))
(goto-char (point-min))
(when (search-forward-regexp (format "\\s %s[*@]?$" curr-file) nil t)
(when (search-forward-regexp (format "\\s %s[*@]?$" (regexp-quote curr-file)) nil t)
(setq hits (+ hits 1))
(dired-mark 1))))
(message "%d files with matching tag marked" hits)))

View file

@ -79,7 +79,7 @@ FILE-TAGS is an alist in the following form:
(setq file (car elt)
tag (cdr elt))
(goto-char (point-min))
(if (search-forward-regexp (format "^%s.*$" file) nil t)
(if (search-forward-regexp (format "^%s.*$" (regexp-quote file)) nil t)
(progn
(setq end (point))
(beginning-of-line)
@ -103,7 +103,7 @@ FILES can be a name of a single file (a string) or a list of file names."
(error "Files must be a string or a list of strings!")))
(dolist (file files)
(goto-char (point-min))
(when (search-forward-regexp (format "^%s;" file) nil t)
(when (search-forward-regexp (format "^%s;" (regexp-quote file)) nil t)
(end-of-line)
(setq end (point))
(beginning-of-line)
@ -125,7 +125,7 @@ Value is a list of all tags for FILE."
(image-dired-sane-db-file)
(image-dired--with-db-file
(let (end (tags ""))
(when (search-forward-regexp (format "^%s" file) nil t)
(when (search-forward-regexp (format "^%s" (regexp-quote file)) nil t)
(end-of-line)
(setq end (point))
(beginning-of-line)
@ -179,7 +179,7 @@ FILE-COMMENTS is an alist on the following form:
(setq file (car elt)
comment (cdr elt))
(goto-char (point-min))
(if (search-forward-regexp (format "^%s.*$" file) nil t)
(if (search-forward-regexp (format "^%s.*$" (regexp-quote file)) nil t)
(progn
(setq end (point))
(beginning-of-line)
@ -236,7 +236,7 @@ Optionally use old comment from FILE as initial value."
(image-dired-sane-db-file)
(image-dired--with-db-file
(let (end comment-beg-pos comment-end-pos comment)
(when (search-forward-regexp (format "^%s" file) nil t)
(when (search-forward-regexp (format "^%s" (regexp-quote file)) nil t)
(end-of-line)
(setq end (point))
(beginning-of-line)