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.

Full log


View this message in rfc822 format

From: Łukasz Stelmach <stlman <at> poczta.fm>
To: 41511 <at> debbugs.gnu.org
Cc: Łukasz Stelmach <stlman <at> poczta.fm>
Subject: bug#41511: [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





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

Previous Next


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