GNU bug report logs - #49926
[PATCH] Fix NNIMAP search command in the gnus

Previous Next

Package: emacs;

Reported by: Jan Stranik <jan <at> stranik.org>

Date: Sat, 7 Aug 2021 13:49:01 UTC

Severity: normal

Tags: moreinfo, patch

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 49926 in the body.
You can then email your comments to 49926 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#49926; Package emacs. (Sat, 07 Aug 2021 13:49:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jan Stranik <jan <at> stranik.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 07 Aug 2021 13:49:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Jan Stranik <jan <at> stranik.org>
To: bug-gnu-emacs <at> gnu.org
Cc: Jan Stranik <jan <at> stranik.org>
Subject: [PATCH] Fix NNIMAP search command in the gnus
Date: Sat,  7 Aug 2021 00:52:30 -0400
In the version 27.2 of emacs, the nnimap search commands stopped
working in gnus.

Good example is a command AT to find a referred
thread in the summary buffer. The observed behaviour was that the
search command returned no error.

The problem turned out to be in the way how imap query is sent to the
server. The function nnimap-make-thread-query used a format function
with foramt specifier %S. For string values with formatting the string
returned is in the format #("string" ....). The result was tha the
query sent to the server looked like:
  23:52:00 [stranik.org] 1980 UID SEARCH (OR HEADER REFERENCES #("<87pmurac3u.fsf <at> stranik.org>" 0 28 (ws-butler-chg chg)) HEADER Message-Id #("<87pmurac3u.fsf <at> stranik.org>" 0 28 (ws-butler-chg chg)))

which is an invalid query.

The change formats the string with %s specifier which discards text
properties.
---
 lisp/gnus/nnimap.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/gnus/nnimap.el b/lisp/gnus/nnimap.el
index 3cf65453f3..33bd6ee5a8 100644
--- a/lisp/gnus/nnimap.el
+++ b/lisp/gnus/nnimap.el
@@ -2295,11 +2295,11 @@ Return the server's response to the SELECT or EXAMINE command."
 		    "")))
 	 (value
 	  (format
-	   "(OR HEADER REFERENCES %S HEADER Message-Id %S)"
+	   "(OR HEADER REFERENCES %s HEADER Message-Id %s)"
 	   id id)))
     (dolist (refid refs value)
       (setq value (format
-		   "(OR (OR HEADER Message-Id %S HEADER REFERENCES %S) %s)"
+		   "(OR (OR HEADER Message-Id %s HEADER REFERENCES %s) %s)"
 		   refid refid value)))))
 
 
-- 
2.31.1





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49926; Package emacs. (Sat, 07 Aug 2021 23:07:01 GMT) Full text and rfc822 format available.

Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Eric Abrahamsen <eric <at> ericabrahamsen.net>
To: Jan Stranik via "Bug reports for GNU Emacs, the Swiss army knife of text
 editors" <bug-gnu-emacs <at> gnu.org>
Cc: Jan Stranik <jan <at> stranik.org>, 49926 <at> debbugs.gnu.org
Subject: Re: bug#49926: [PATCH] Fix NNIMAP search command in the gnus
Date: Sat, 07 Aug 2021 16:06:08 -0700
Jan Stranik via "Bug reports for GNU Emacs, the Swiss army knife of text
editors" <bug-gnu-emacs <at> gnu.org> writes:

> In the version 27.2 of emacs, the nnimap search commands stopped
> working in gnus.
>
> Good example is a command AT to find a referred
> thread in the summary buffer. The observed behaviour was that the
> search command returned no error.
>
> The problem turned out to be in the way how imap query is sent to the
> server. The function nnimap-make-thread-query used a format function
> with foramt specifier %S. For string values with formatting the string
> returned is in the format #("string" ....). The result was tha the
> query sent to the server looked like:
>   23:52:00 [stranik.org] 1980 UID SEARCH (OR HEADER REFERENCES #("<87pmurac3u.fsf <at> stranik.org>" 0 28 (ws-butler-chg chg)) HEADER Message-Id #("<87pmurac3u.fsf <at> stranik.org>" 0 28 (ws-butler-chg chg)))
>
> which is an invalid query.
>
> The change formats the string with %s specifier which discards text
> properties.

But that also removes the quoting around the message ids -- are we sure
that's still valid?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49926; Package emacs. (Sat, 07 Aug 2021 23:07:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49926; Package emacs. (Sun, 08 Aug 2021 19:27:02 GMT) Full text and rfc822 format available.

Message #14 received at 49926 <at> debbugs.gnu.org (full text, mbox):

From: Eric Abrahamsen <eric <at> ericabrahamsen.net>
To: Jan Stranik <jan <at> stranik.org>
Cc: 49926 <at> debbugs.gnu.org
Subject: Re: bug#49926: [PATCH] Fix NNIMAP search command in the gnus
Date: Sun, 08 Aug 2021 12:26:28 -0700
On 08/08/21 14:29 PM, Jan Stranik wrote:
> On 08/07/21 16:06 PM, Eric Abrahamsen wrote:
>> Jan Stranik via "Bug reports for GNU Emacs, the Swiss army knife of text
>> editors" <bug-gnu-emacs <at> gnu.org> writes:
>>
>>> In the version 27.2 of emacs, the nnimap search commands stopped
>>> working in gnus.
>>>
>>> Good example is a command AT to find a referred
>>> thread in the summary buffer. The observed behaviour was that the
>>> search command returned no error.
>>>
>>> The problem turned out to be in the way how imap query is sent to the
>>> server. The function nnimap-make-thread-query used a format function
>>> with foramt specifier %S. For string values with formatting the string
>>> returned is in the format #("string" ....). The result was tha the
>>> query sent to the server looked like:
>>>   23:52:00 [stranik.org] 1980 UID SEARCH (OR HEADER REFERENCES
>>> #("<87pmurac3u.fsf <at> stranik.org>" 0 28 (ws-butler-chg chg)) HEADER
>>> Message-Id #("<87pmurac3u.fsf <at> stranik.org>" 0 28 (ws-butler-chg
>>> chg)))
>>>
>>> which is an invalid query.
>>>
>>> The change formats the string with %s specifier which discards text
>>> properties.
>>
>> But that also removes the quoting around the message ids -- are we sure
>> that's still valid?

(Putting debbugs back in the cc)

> You're right. Per the specification, the strings are expected to be
> either in literal or quotes syntax
> (https://datatracker.ietf.org/doc/html/rfc3501#section-4.3).
>
> Adding quotes back to make the strings to be in quoted syntax.
>
> Interestingly, dovecot seems to accept the strings without quotes as
> well.

I've found dovecot to be generally pretty permissive, though obviously
we want to stick closely to the RFCs here.

> New patch attached.

This seems fine, but just thinking out loud: is there anything else the
%S could potentially get us, here? Extra quoting of special characters?

Our other option would be to explicitly remove properties from the
strings beforehand; I'm just wondering if one approach is preferable
over another.

Eric




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49926; Package emacs. (Sat, 06 Nov 2021 02:40:01 GMT) Full text and rfc822 format available.

Message #17 received at 49926 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Eric Abrahamsen <eric <at> ericabrahamsen.net>
Cc: Jan Stranik <jan <at> stranik.org>, 49926 <at> debbugs.gnu.org
Subject: Re: bug#49926: [PATCH] Fix NNIMAP search command in the gnus
Date: Sat, 06 Nov 2021 03:39:35 +0100
Eric Abrahamsen <eric <at> ericabrahamsen.net> writes:

> (Putting debbugs back in the cc)

[...]

>> New patch attached.

The new version of the patch didn't make it to the bug tracker.  Could
you re-send it, Jan?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) moreinfo. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 06 Nov 2021 02:40:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49926; Package emacs. (Sat, 06 Nov 2021 14:56:02 GMT) Full text and rfc822 format available.

Message #22 received at 49926 <at> debbugs.gnu.org (full text, mbox):

From: Eric Abrahamsen <eric <at> ericabrahamsen.net>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Jan Stranik <jan <at> stranik.org>, 49926 <at> debbugs.gnu.org
Subject: Re: bug#49926: [PATCH] Fix NNIMAP search command in the gnus
Date: Sat, 06 Nov 2021 07:55:29 -0700
[Message part 1 (text/plain, inline)]
On 11/06/21 03:39 AM, Lars Ingebrigtsen wrote:
> Eric Abrahamsen <eric <at> ericabrahamsen.net> writes:
>
>> (Putting debbugs back in the cc)
>
> [...]
>
>>> New patch attached.
>
> The new version of the patch didn't make it to the bug tracker.  Could
> you re-send it, Jan?

He sent that directly to me, attached here. I guess I don't see any
problem with it.

[0001-Fix-NNIMAP-search-command-in-the-gnus.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49926; Package emacs. (Sat, 06 Nov 2021 18:27:02 GMT) Full text and rfc822 format available.

Message #25 received at 49926 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Eric Abrahamsen <eric <at> ericabrahamsen.net>
Cc: Jan Stranik <jan <at> stranik.org>, 49926 <at> debbugs.gnu.org
Subject: Re: bug#49926: [PATCH] Fix NNIMAP search command in the gnus
Date: Sat, 06 Nov 2021 19:26:09 +0100
Eric Abrahamsen <eric <at> ericabrahamsen.net> writes:

> -	   "(OR HEADER REFERENCES %S HEADER Message-Id %S)"
> +	   "(OR HEADER REFERENCES \"%s\" HEADER Message-Id \"%s\")"
>  	   id id)))

This is not correct -- this would yield an incorrect syntax for IDs that
contain a " character.  I've now fixed this in emacs-28 by just removing
the text properties from `id' instead.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug marked as fixed in version 28.1, send any further explanations to 49926 <at> debbugs.gnu.org and Jan Stranik <jan <at> stranik.org> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 06 Nov 2021 18:27:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49926; Package emacs. (Sat, 06 Nov 2021 19:15:02 GMT) Full text and rfc822 format available.

Message #30 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Eric Abrahamsen <eric <at> ericabrahamsen.net>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#49926: [PATCH] Fix NNIMAP search command in the gnus
Date: Sat, 06 Nov 2021 12:14:12 -0700
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Eric Abrahamsen <eric <at> ericabrahamsen.net> writes:
>
>> -	   "(OR HEADER REFERENCES %S HEADER Message-Id %S)"
>> +	   "(OR HEADER REFERENCES \"%s\" HEADER Message-Id \"%s\")"
>>  	   id id)))
>
> This is not correct -- this would yield an incorrect syntax for IDs that
> contain a " character.  I've now fixed this in emacs-28 by just removing
> the text properties from `id' instead.

Sounds good.





bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 05 Dec 2021 12:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 140 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.