Subject: Re: bug#76732: 30.1; image-dired fails with files with only open bracket

From: Stefan Kangas <[email-masked]>
Date: Tue, 4 Mar 2025 01:59:56 -0800

Sanel Zukan <[email-masked]> writes:

> Hi,
>
> When image-dired is run on folder where at least one file has open
> bracket ('[') in it's name, without closing bracket, it will fail with
> this stacktrace:
>
> Debugger entered--Lisp error: (invalid-regexp "Unmatched [ or [^")
>   search-forward-regexp("^/home/user/ooo/[img.png" nil t)
>   image-dired-list-tags("/home/user/ooo/[img.png")
>   image-dired-insert-thumbnail("/home/user/.emacs.d/image-dired/7099b45a60beaf2cdfa5d644d7cc5ad99d915ca0.jpg" "/home/user/ooo/[img.png" #<buffer ooo>)
>   image-dired-display-thumbs()
>   image-dired("~/ooo/")
>   funcall-interactively(image-dired "~/ooo/")
>   call-interactively(image-dired record nil)
>   command-execute(image-dired record)
>   execute-extended-command(nil "image-dired" nil)
>   funcall-interactively(execute-extended-command nil "image-dired" nil)
>   call-interactively(execute-extended-command nil nil)
>   command-execute(execute-extended-command)
>
> To reproduce it:
>
>  1. Start Emacs with "emacs -Q"
>  2. Create temporary folder and copy one png file to it and rename it to
>  '[img.png'.
>  3. Try to open that folder with image-dired. You should get stacktrace
>  as above.
>
> It will fail also with files like 'im[g.png' but not with files with
> only closed bracket. E.g. this works: ']img.png' or 'im]g.png'.

Thanks for the bug report!

This is actually already fixed on master.  I have now backported the fix
to the emacs-30 branch, which means that it will be in Emacs 30.2.

I'm therefore closing this bug report.