From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Kangas Newsgroups: gmane.emacs.bugs Subject: bug#73445: [PATCH] image-dired: quote file name fore search-forward-regexp Date: Sun, 15 Dec 2024 18:56:15 +0000 Message-ID: References: <871q19k5v1.fsf@gmx.com> <87h67896bi.fsf@gmx.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40412"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 73445-done@debbugs.gnu.org To: Vitaliy Chepelev Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Dec 15 19:58:31 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tMtp1-000AJv-Cj for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 15 Dec 2024 19:58:31 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tMtoe-0006wL-OP; Sun, 15 Dec 2024 13:58:08 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tMtoZ-0006vX-Vd for bug-gnu-emacs@gnu.org; Sun, 15 Dec 2024 13:58:04 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tMtoZ-0008GX-Mx for bug-gnu-emacs@gnu.org; Sun, 15 Dec 2024 13:58:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=Date:MIME-Version:References:In-Reply-To:From:To:Subject; bh=u9F433RPgqVcbf84Q7de13I8AOZeBfBWOoYkuj5ol3c=; b=psGo0sx0QS6vNJJKxNnS18x4UqGdR+UVizt4VPqdX0ctjU6HvevNF0gDWHZyFG3OAsGp15pFrJecxJ19xXvGFHaIgv+7Ru7s6ioCptJ1tG2o9eAaeYp1Aqnsffbro0AHIOoE2bNNg/g67K32Pxe3QROypxXWLu3cJx0v2DOAK3kihGu8C3x/o2BORgH60TiyapW/kIxYS8tpKaRWcpwS+wTEwOrOaz7zPN475nyU+94lpobJzIUAcBv7QSl0VelT+/48vrW3vOv6WsT6dkte1dMkiwuS3KVXfabUPrQ8stO6JiPN6eiTalmoHRidJWCJyInpO2MTPVwim2jCrCtJEA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tMtoY-0005Lf-Gt for bug-gnu-emacs@gnu.org; Sun, 15 Dec 2024 13:58:02 -0500 Resent-From: Stefan Kangas Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Sun, 15 Dec 2024 18:58:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 73445 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Mail-Followup-To: 73445@debbugs.gnu.org, stefankangas@gmail.com, vitalij@gmx.com Original-Received: via spool by 73445-done@debbugs.gnu.org id=D73445.173428904920509 (code D ref 73445); Sun, 15 Dec 2024 18:58:02 +0000 Original-Received: (at 73445-done) by debbugs.gnu.org; 15 Dec 2024 18:57:29 +0000 Original-Received: from localhost ([127.0.0.1]:52099 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tMto0-0005Kg-Dr for submit@debbugs.gnu.org; Sun, 15 Dec 2024 13:57:29 -0500 Original-Received: from mail-ed1-f46.google.com ([209.85.208.46]:45257) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tMtny-0005KO-R3 for 73445-done@debbugs.gnu.org; Sun, 15 Dec 2024 13:57:27 -0500 Original-Received: by mail-ed1-f46.google.com with SMTP id 4fb4d7f45d1cf-5d122cf8dd1so5817098a12.2 for <73445-done@debbugs.gnu.org>; Sun, 15 Dec 2024 10:57:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734288976; x=1734893776; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:from:to:cc:subject:date:message-id:reply-to; bh=u9F433RPgqVcbf84Q7de13I8AOZeBfBWOoYkuj5ol3c=; b=HJZHxOUbkzRiuMCNREhcfqoHHCltfW8GTJzwWetZA6ObVPbqVqJEB3yhy5tifBIMM7 TWjzezRoAjNH2CSsTWjA2N+nzfoEclui7M/cegPsJixD8ELmxYJhAR5RNEsaC9O8E9q3 J+YcGFQCB6/FzRZLTVERczha00EDnnuBCYC8k42C60/vEAo0BljNjEypp+4WjJ/PsfPw VObUEOaO7zBjfqrEtA+qpruZvdK1SB+lnPTlBVrsgTgbbpK4GT6dIgQkP8cJTloQn5q8 CmZILIf0gtGO3/XLAgtL032IaaoOa0RNsAze0IufN3tmLc2CLYqBWhr1/rqAS9bcqZN4 ralw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734288976; x=1734893776; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=u9F433RPgqVcbf84Q7de13I8AOZeBfBWOoYkuj5ol3c=; b=vWD0u+faLHymJ/8M4huU9D6/P7165BJiXeWbkkdQJnm5/CPHrg24G8HzYRHYgR8Ksm ayDXiRtlG700sUVKBuPiiUel8W6IS+4t6g9Be7MCD6WAPNRG5YosWy3jU2xv9W+Uiqbu 4WcvsUiNt2sIouALDNwn6Hac6105luwpJUuK5SElaYRQINVwbfvbqTqj8Rx/BX8sCckC EGfNDHd9U3T7eAXho36bRRfuWPdrN1ANEUop9xkpv0ix4sqgyqRES8u+btwE8ipr6dzf vxKnssqhXhoEUhx4ivakoOs1DMDiMRI9JQYTebX33UmpGPRI6q7YAlsK/gIg/LdqLcXd BEzA== X-Gm-Message-State: AOJu0Yz9HSlMi58glhNbQifJk9MSox2PZExWXv2ivU+f5icPHwB8foTM PdI6FBUp6USumxe4o2Gas743ArDuKmXmBU1tQs+/wwK3G790dyOMsI92rcHMzFrQ99TRrmlUzkQ cfyNGNwwUHkuf/6NMsvnu6B8a96k= X-Gm-Gg: ASbGncs2DtNgDPqrCnHvaWWtO/Sz4CLmNXv8HCC+X1DCh/eynoc+Zsxig3/YcaTIfmD oHM4jz7zDWLooP5YgMBFZvIIjxFvn7raiphKd9Ws= X-Google-Smtp-Source: AGHT+IFfe/uHbcQX0NzzWxwmBheYY83C3P67PuxIsRgwyY9hdVwjxVi0P6I568/kzhd9QS8QyDVjWUduf4SU+rrcNzI= X-Received: by 2002:a05:6402:3885:b0:5d0:b931:8db9 with SMTP id 4fb4d7f45d1cf-5d63c32efcemr8965343a12.20.1734288975624; Sun, 15 Dec 2024 10:56:15 -0800 (PST) Original-Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Sun, 15 Dec 2024 18:56:15 +0000 In-Reply-To: <87h67896bi.fsf@gmx.com> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:297128 Archived-At: Version: 31.1 Vitaliy Chepelev writes: > From fixed inside .patch. I don't know how to "include a ChangeLog > according to CONTRIBUTE", sorry. Thanks for the patch. Installed on master as commit 7930fe2f44f. > From d0e7b67e10d3ecb34969c0af18ef6317fd96636d Mon Sep 17 00:00:00 2001 > From: vitalij > Date: Tue, 24 Sep 2024 04:25:13 +0000 > Subject: [PATCH] image-dired: quote file name fore search-forward-regexp > > For example when you have file with name "file[image].jpg". and use M-x image-dired you will have error: image-dired-list-tags: Invalid regexp: "Unmatched [ or [^" > --- > lisp/image/image-dired-dired.el | 2 +- > 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 7219a10..c4e82e9 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." > (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))) > diff --git a/lisp/image/image-dired-tags.el b/lisp/image/image-dired-tags.el > index 54595ad..828372e 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: > (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) > -- > 2.44.2 > > > Stefan Kangas writes: > >> Stefan Kangas writes: >> >>> tags 73445 + pending >>> thanks >>> >>> Could you resend the patch with a correct "From" line so that we >>> can get the attribution right? >>> >>> Currently, the "From" line says: >>> >>>> From: none >>> >>> Other than that, LGTM. >>> >>> Bonus points if you include a ChangeLog according to CONTRIBUTE, but I >>> can easily write that for you. >> >> Ping! > > -- > Best regards, > Vitaliy Chepelev > Python Middle Data Scientist > https://t.me/vitdata > Magic numbers: 7850B0B5E3F536601D2E6A9DE1C43E074A047699