Subject: bug#41511: [PATCH] Decode group name before matching against gnus-parameters

From: Łukasz Stelmach <[email-masked]>
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