]> git.eshelyaron.com Git - emacs.git/commitdiff
image-dired: Don't croak on file names with regexp characters
authorVitaliy Chepelev <vitalij@gmx.com>
Tue, 24 Sep 2024 04:25:13 +0000 (04:25 +0000)
committerEshel Yaron <me@eshelyaron.com>
Mon, 23 Dec 2024 14:58:02 +0000 (15:58 +0100)
* 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)

lisp/image/image-dired-dired.el
lisp/image/image-dired-tags.el

index 7219a106ca838f4d8c78c4514fe354cf4a807fca..c4e82e906d1c574aae1eb4e40e8252380db9afc0 100644 (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)))
index 54595adc14730eb67bf679d53531659ba73660e4..828372e008afdf54a6fc071f13fde553df841f98 100644 (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)