all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#41511: [PATCH] Decode group name before matching against gnus-parameters
@ 2020-05-24 16:59 Łukasz Stelmach
  2020-05-24 17:16 ` bug#41511: [PATCH v2] " Łukasz Stelmach
  0 siblings, 1 reply; 5+ messages in thread
From: Łukasz Stelmach @ 2020-05-24 16:59 UTC (permalink / raw)
  To: 41511; +Cc: Łukasz Stelmach

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






^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#41511: [PATCH v2] Decode group name before matching against gnus-parameters
  2020-05-24 16:59 bug#41511: [PATCH] Decode group name before matching against gnus-parameters Łukasz Stelmach
@ 2020-05-24 17:16 ` Łukasz Stelmach
  2020-05-24 22:04   ` Eric Abrahamsen
  0 siblings, 1 reply; 5+ messages in thread
From: Łukasz Stelmach @ 2020-05-24 17:16 UTC (permalink / raw)
  To: 41511; +Cc: Łukasz Stelmach

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






^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#41511: [PATCH v2] Decode group name before matching against gnus-parameters
  2020-05-24 17:16 ` bug#41511: [PATCH v2] " Łukasz Stelmach
@ 2020-05-24 22:04   ` Eric Abrahamsen
  2020-05-25  7:29     ` Łukasz Stelmach
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Abrahamsen @ 2020-05-24 22:04 UTC (permalink / raw)
  To: Łukasz Stelmach; +Cc: 41511

Łukasz Stelmach <stlman@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?





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#41511: [PATCH v2] Decode group name before matching against gnus-parameters
  2020-05-24 22:04   ` Eric Abrahamsen
@ 2020-05-25  7:29     ` Łukasz Stelmach
  2020-05-25 14:43       ` Eric Abrahamsen
  0 siblings, 1 reply; 5+ messages in thread
From: Łukasz Stelmach @ 2020-05-25  7:29 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: 41511

[-- Attachment #1: Type: text/plain, Size: 859 bytes --]

Eric Abrahamsen <eric@ericabrahamsen.net> writes:
> Łukasz Stelmach <stlman@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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 617 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#41511: [PATCH v2] Decode group name before matching against gnus-parameters
  2020-05-25  7:29     ` Łukasz Stelmach
@ 2020-05-25 14:43       ` Eric Abrahamsen
  0 siblings, 0 replies; 5+ messages in thread
From: Eric Abrahamsen @ 2020-05-25 14:43 UTC (permalink / raw)
  To: Łukasz Stelmach; +Cc: Debbugs control, 41511

close 41511
thanks

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

> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>> Łukasz Stelmach <stlman@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 :)





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-05-25 14:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-24 16:59 bug#41511: [PATCH] Decode group name before matching against gnus-parameters Łukasz Stelmach
2020-05-24 17:16 ` bug#41511: [PATCH v2] " Łukasz Stelmach
2020-05-24 22:04   ` Eric Abrahamsen
2020-05-25  7:29     ` Łukasz Stelmach
2020-05-25 14:43       ` Eric Abrahamsen

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.