GNU bug report logs - #41511
[PATCH] Decode group name before matching against gnus-parameters

Previous Next

Package: emacs;

Reported by: Łukasz Stelmach <stlman <at> poczta.fm>

Date: Sun, 24 May 2020 17:01:02 UTC

Severity: normal

Tags: patch

Done: Eric Abrahamsen <eric <at> ericabrahamsen.net>

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 41511 in the body.
You can then email your comments to 41511 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#41511; Package emacs. (Sun, 24 May 2020 17:01:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Łukasz Stelmach <stlman <at> poczta.fm>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 24 May 2020 17:01:02 GMT) Full text and rfc822 format available.

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

From: Łukasz Stelmach <stlman <at> poczta.fm>
To: bug-gnu-emacs <at> gnu.org
Cc: Łukasz Stelmach <stlman <at> poczta.fm>
Subject: [PATCH] Decode group name before matching against gnus-parameters
Date: Sun, 24 May 2020 18:59:40 +0200
Group names in Gnus are stored and processed as strings of bytes
(e.g. "Wiadomo\305\233ci-\305\233mieci") while regular expressions in
gnus-parameters are encoded as multibyte strings (e.g. "Wiadomości-śmieci")
and matching the latter aginst the former doesn't work. Parameters set
for groups with non-ascii characters in their names cannot be retrieved.

To fix this problem group name needs to be decoded before being matched
against a regexp.

* gnus.el (gnus-parameters-get-parameter, gnus-group-fast-parameter,
gnus-define-group-parameter): Decode a group name before matching against
a regexp.
---
 lisp/gnus/gnus.el | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/lisp/gnus/gnus.el b/lisp/gnus/gnus.el
index caeab7f55a..e7621872d8 100644
--- a/lisp/gnus/gnus.el
+++ b/lisp/gnus/gnus.el
@@ -947,6 +947,7 @@ REST is a plist of following:
 		(string-match ,variable name))
 	       (,variable
 		(let ((alist ,variable)
+		      (decoded-name (gnus-group-decoded-name name))
 		      elem value)
 		  (while (setq elem (pop alist))
 		    (when (and name
@@ -959,6 +960,7 @@ REST is a plist of following:
 	  (and name
 	       (or (gnus-group-find-parameter name ',param ,(and type t))
 		   (let ((alist ,variable)
+			 (decoded-name (gnus-group-decoded-name name))
 			 elem value)
 		     (while (setq elem (pop alist))
 		       (when (and name
@@ -3513,9 +3515,10 @@ You should probably use `gnus-find-method-for-group' instead."
   (let ((case-fold-search (if (eq gnus-parameters-case-fold-search 'default)
 			      case-fold-search
 			    gnus-parameters-case-fold-search))
+	(decoded-group (gnus-group-decoded-name group))
 	params-list)
     (dolist (elem gnus-parameters)
-      (when (string-match (car elem) group)
+      (when (string-match (car elem) decoded-group)
 	(setq params-list
 	      (nconc (gnus-expand-group-parameters
 		      (car elem) (cdr elem) group)
@@ -3569,7 +3572,8 @@ The function `gnus-group-find-parameter' will do that for you."
   (let* ((params (funcall gnus-group-get-parameter-function group))
 	 ;; Start easy, check the "real" group parameters.
 	 (simple-results
-	  (gnus-group-parameter-value params symbol allow-list t)))
+	  (gnus-group-parameter-value params symbol allow-list t))
+	 (decoded-group (gnus-group-decoded-name group)))
     (if simple-results
 	;; Found results; return them.
 	(car simple-results)
@@ -3582,7 +3586,7 @@ The function `gnus-group-find-parameter' will do that for you."
 	  (setq head (car tail)
 		tail (cdr tail))
 	  ;; The car is regexp matching for matching the group name.
-	  (when (string-match (car head) group)
+	  (when (string-match (car head) decoded-group)
 	    ;; The cdr is the parameters.
 	    (let ((this-result
 		   (gnus-group-parameter-value (cdr head) symbol allow-list t)))
-- 
2.20.1





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41511; Package emacs. (Sun, 24 May 2020 17:17:02 GMT) Full text and rfc822 format available.

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

From: Łukasz Stelmach <stlman <at> poczta.fm>
To: 41511 <at> debbugs.gnu.org
Cc: Łukasz Stelmach <stlman <at> poczta.fm>
Subject: [PATCH v2] Decode group name before matching against gnus-parameters
Date: Sun, 24 May 2020 19:16:15 +0200
Group names in Gnus are stored and processed as strings of bytes
(e.g. "Wiadomo\305\233ci-\305\233mieci") while regular expressions in
gnus-parameters are encoded as multibyte strings (e.g. "Wiadomości-śmieci")
and matching the latter aginst the former doesn't work. Parameters set
for groups with non-ascii characters in their names cannot be retrieved.

To fix this problem group name needs to be decoded before being matched
against a regexp.

* gnus.el (gnus-parameters-get-parameter, gnus-group-fast-parameter,
gnus-define-group-parameter): Decode a group name before matching against
a regexp.
---
 lisp/gnus/gnus.el | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

v2:
  - actually use the decoded-name instead of name in
  gnus-define-group-parameter

diff --git a/lisp/gnus/gnus.el b/lisp/gnus/gnus.el
index caeab7f55a..e1fea35fdd 100644
--- a/lisp/gnus/gnus.el
+++ b/lisp/gnus/gnus.el
@@ -947,10 +947,11 @@ REST is a plist of following:
 		(string-match ,variable name))
 	       (,variable
 		(let ((alist ,variable)
+		      (decoded-name (gnus-group-decoded-name name))
 		      elem value)
 		  (while (setq elem (pop alist))
 		    (when (and name
-			       (string-match (car elem) name))
+			       (string-match (car elem) decoded-name))
 		      (setq alist nil
 			    value (cdr elem))))
 		  (if (consp value) (car value) value))))))
@@ -959,10 +960,11 @@ REST is a plist of following:
 	  (and name
 	       (or (gnus-group-find-parameter name ',param ,(and type t))
 		   (let ((alist ,variable)
+			 (decoded-name (gnus-group-decoded-name name))
 			 elem value)
 		     (while (setq elem (pop alist))
 		       (when (and name
-				  (string-match (car elem) name))
+				  (string-match (car elem) decoded-name))
 			 (setq alist nil
 			       value (cdr elem))))
 		     ,(if type
@@ -3513,9 +3515,10 @@ You should probably use `gnus-find-method-for-group' instead."
   (let ((case-fold-search (if (eq gnus-parameters-case-fold-search 'default)
 			      case-fold-search
 			    gnus-parameters-case-fold-search))
+	(decoded-group (gnus-group-decoded-name group))
 	params-list)
     (dolist (elem gnus-parameters)
-      (when (string-match (car elem) group)
+      (when (string-match (car elem) decoded-group)
 	(setq params-list
 	      (nconc (gnus-expand-group-parameters
 		      (car elem) (cdr elem) group)
@@ -3569,7 +3572,8 @@ The function `gnus-group-find-parameter' will do that for you."
   (let* ((params (funcall gnus-group-get-parameter-function group))
 	 ;; Start easy, check the "real" group parameters.
 	 (simple-results
-	  (gnus-group-parameter-value params symbol allow-list t)))
+	  (gnus-group-parameter-value params symbol allow-list t))
+	 (decoded-group (gnus-group-decoded-name group)))
     (if simple-results
 	;; Found results; return them.
 	(car simple-results)
@@ -3582,7 +3586,7 @@ The function `gnus-group-find-parameter' will do that for you."
 	  (setq head (car tail)
 		tail (cdr tail))
 	  ;; The car is regexp matching for matching the group name.
-	  (when (string-match (car head) group)
+	  (when (string-match (car head) decoded-group)
 	    ;; The cdr is the parameters.
 	    (let ((this-result
 		   (gnus-group-parameter-value (cdr head) symbol allow-list t)))
-- 
2.20.1





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41511; Package emacs. (Sun, 24 May 2020 22:05:02 GMT) Full text and rfc822 format available.

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

From: Eric Abrahamsen <eric <at> ericabrahamsen.net>
To: Łukasz Stelmach <stlman <at> poczta.fm>
Cc: 41511 <at> debbugs.gnu.org
Subject: Re: bug#41511: [PATCH v2] Decode group name before matching against
 gnus-parameters
Date: Sun, 24 May 2020 15:04:19 -0700
Łukasz Stelmach <stlman <at> poczta.fm> writes:

> Group names in Gnus are stored and processed as strings of bytes
> (e.g. "Wiadomo\305\233ci-\305\233mieci") while regular expressions in
> gnus-parameters are encoded as multibyte strings (e.g. "Wiadomości-śmieci")
> and matching the latter aginst the former doesn't work. Parameters set
> for groups with non-ascii characters in their names cannot be retrieved.

Group names in Gnus have been fully decoded strings for six months or
more -- are you seeing this bug in master?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41511; Package emacs. (Mon, 25 May 2020 07:30:03 GMT) Full text and rfc822 format available.

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

From: Łukasz Stelmach <stlman <at> poczta.fm>
To: Eric Abrahamsen <eric <at> ericabrahamsen.net>
Cc: 41511 <at> debbugs.gnu.org
Subject: Re: bug#41511: [PATCH v2] Decode group name before matching against
 gnus-parameters
Date: Mon, 25 May 2020 09:29:07 +0200
[Message part 1 (text/plain, inline)]
Eric Abrahamsen <eric <at> ericabrahamsen.net> writes:
> Łukasz Stelmach <stlman <at> poczta.fm> writes:
>
>> Group names in Gnus are stored and processed as strings of bytes
>> (e.g. "Wiadomo\305\233ci-\305\233mieci") while regular expressions in
>> gnus-parameters are encoded as multibyte strings (e.g. "Wiadomości-śmieci")
>> and matching the latter aginst the former doesn't work. Parameters set
>> for groups with non-ascii characters in their names cannot be retrieved.
>
> Group names in Gnus have been fully decoded strings for six months or
> more -- are you seeing this bug in master?

Shame on me. I created the patch on 26.1, cherry-picked it to master,
tested and assumed it was still needed because it applied without issues
and worked as expected.

This bug can be closed then.

Kind regards,
-- 
Miłego dnia,
Łukasz Stelmach
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41511; Package emacs. (Mon, 25 May 2020 14:44:01 GMT) Full text and rfc822 format available.

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

From: Eric Abrahamsen <eric <at> ericabrahamsen.net>
To: Łukasz Stelmach <stlman <at> poczta.fm>
Cc: Debbugs control <control <at> debbugs.gnu.org>, 41511 <at> debbugs.gnu.org
Subject: Re: bug#41511: [PATCH v2] Decode group name before matching against
 gnus-parameters
Date: Mon, 25 May 2020 07:43:08 -0700
close 41511
thanks

Łukasz Stelmach <stlman <at> poczta.fm> writes:

> Eric Abrahamsen <eric <at> ericabrahamsen.net> writes:
>> Łukasz Stelmach <stlman <at> poczta.fm> writes:
>>
>>> Group names in Gnus are stored and processed as strings of bytes
>>> (e.g. "Wiadomo\305\233ci-\305\233mieci") while regular expressions in
>>> gnus-parameters are encoded as multibyte strings (e.g. "Wiadomości-śmieci")
>>> and matching the latter aginst the former doesn't work. Parameters set
>>> for groups with non-ascii characters in their names cannot be retrieved.
>>
>> Group names in Gnus have been fully decoded strings for six months or
>> more -- are you seeing this bug in master?
>
> Shame on me. I created the patch on 26.1, cherry-picked it to master,
> tested and assumed it was still needed because it applied without issues
> and worked as expected.

Good news! You had me very worried for a second there :)




bug closed, send any further explanations to 41511 <at> debbugs.gnu.org and Łukasz Stelmach <stlman <at> poczta.fm> Request was from Eric Abrahamsen <eric <at> ericabrahamsen.net> to control <at> debbugs.gnu.org. (Mon, 25 May 2020 14:44:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 23 Jun 2020 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 359 days ago.

Previous Next


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