all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#29749: 27.0.50; Fix header value extraction in Gnus registry
@ 2017-12-17  1:35 Eric Abrahamsen
  2017-12-18  0:35 ` Ted Zlatanov
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Abrahamsen @ 2017-12-17  1:35 UTC (permalink / raw)
  To: 29749

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


The Gnus registry extracts some header values from messages using
`gnus-registry-fetch-header-fast'. There are two problems with this:

1. It is called with its arguments reversed which (by luck) causes it to
always return nil.

2. If it were called correctly it would raise an error, as it tries to
use `assq' to find a string key in a vector. Maybe `gnus-data-header'
used to return a different value, but so far as I can tell this hasn't
worked for quite some time.

It's a bug, but it's one that hasn't done much harm for a while, so I'm
proposing this for master.

Eric


In GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.26)
 of 2017-12-16 built on clem
Repository revision: 7ef18c6ea5b2cb6450c0f960445b26cad03d200e

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-Gnus-registry-header-extraction.patch --]
[-- Type: text/x-patch, Size: 2248 bytes --]

From 7ef18c6ea5b2cb6450c0f960445b26cad03d200e Mon Sep 17 00:00:00 2001
From: Eric Abrahamsen <eric@ericabrahamsen.net>
Date: Sat, 16 Dec 2017 14:03:18 -0800
Subject: [PATCH] Fix Gnus registry header extraction

* lisp/gnus/gnus-registry.el (gnus-registry-fetch-recipients-fast,
  gnus-registry-fetch-sender-fast): First, delete
  `gnus-registry-fetch-header-fast'. It was being called with reversed
  arguments, and thus always returned nil, but even if the argument
  order was correct it would have raised an error, as it was trying to
  `assq' a string in a vector. Instead, just have these two functions
  do their own work, as they're doing fairly different things.
---
 lisp/gnus/gnus-registry.el | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/lisp/gnus/gnus-registry.el b/lisp/gnus/gnus-registry.el
index 466238d252..7345c084db 100644
--- a/lisp/gnus/gnus-registry.el
+++ b/lisp/gnus/gnus-registry.el
@@ -844,21 +844,17 @@ gnus-registry-fetch-simplified-message-subject-fast
     nil))
 
 (defun gnus-registry-fetch-sender-fast (article)
-  (gnus-registry-fetch-header-fast "from" article))
+  (when-let* ((data (and (numberp article)
+			 (assoc article (gnus-data-list nil)))))
+    (mail-header-from (gnus-data-header data))))
 
 (defun gnus-registry-fetch-recipients-fast (article)
-  (gnus-registry-sort-addresses
-   (or (ignore-errors (gnus-registry-fetch-header-fast "Cc" article)) "")
-   (or (ignore-errors (gnus-registry-fetch-header-fast "To" article)) "")))
-
-(defun gnus-registry-fetch-header-fast (article header)
-  "Fetch the HEADER quickly, using the internal gnus-data-list function."
-  (if (and (numberp article)
-           (assoc article (gnus-data-list nil)))
-      (gnus-string-remove-all-properties
-       (cdr (assq header (gnus-data-header
-                          (assoc article (gnus-data-list nil))))))
-    nil))
+  (when-let* ((data (and (numberp article)
+			 (assoc article (gnus-data-list nil))))
+	      (extra (mail-header-extra (gnus-data-header data))))
+    (gnus-registry-sort-addresses
+     (or (cdr (assq 'Cc extra)) "")
+     (or (cdr (assq 'To extra)) ""))))
 
 ;; registry marks glue
 (defun gnus-registry-do-marks (type function)
-- 
2.15.1


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

* bug#29749: 27.0.50; Fix header value extraction in Gnus registry
  2017-12-17  1:35 bug#29749: 27.0.50; Fix header value extraction in Gnus registry Eric Abrahamsen
@ 2017-12-18  0:35 ` Ted Zlatanov
  2017-12-18 18:12   ` Eric Abrahamsen
  0 siblings, 1 reply; 3+ messages in thread
From: Ted Zlatanov @ 2017-12-18  0:35 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: 29749

On Sat, 16 Dec 2017 17:35:27 -0800 Eric Abrahamsen <eric@ericabrahamsen.net> wrote: 

EA> The Gnus registry extracts some header values from messages using
EA> `gnus-registry-fetch-header-fast'. There are two problems with this:

EA> 1. It is called with its arguments reversed which (by luck) causes it to
EA> always return nil.

EA> 2. If it were called correctly it would raise an error, as it tries to
EA> use `assq' to find a string key in a vector. Maybe `gnus-data-header'
EA> used to return a different value, but so far as I can tell this hasn't
EA> worked for quite some time.

EA> It's a bug, but it's one that hasn't done much harm for a while, so I'm
EA> proposing this for master.

Thank you so much for patching that. I'm happy with your fix.

Ted





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

* bug#29749: 27.0.50; Fix header value extraction in Gnus registry
  2017-12-18  0:35 ` Ted Zlatanov
@ 2017-12-18 18:12   ` Eric Abrahamsen
  0 siblings, 0 replies; 3+ messages in thread
From: Eric Abrahamsen @ 2017-12-18 18:12 UTC (permalink / raw)
  To: 29749


On 12/17/17 19:35 PM, Ted Zlatanov wrote:
> On Sat, 16 Dec 2017 17:35:27 -0800 Eric Abrahamsen <eric@ericabrahamsen.net> wrote: 
>
> EA> The Gnus registry extracts some header values from messages using
> EA> `gnus-registry-fetch-header-fast'. There are two problems with this:
>
> EA> 1. It is called with its arguments reversed which (by luck) causes it to
> EA> always return nil.
>
> EA> 2. If it were called correctly it would raise an error, as it tries to
> EA> use `assq' to find a string key in a vector. Maybe `gnus-data-header'
> EA> used to return a different value, but so far as I can tell this hasn't
> EA> worked for quite some time.
>
> EA> It's a bug, but it's one that hasn't done much harm for a while, so I'm
> EA> proposing this for master.
>
> Thank you so much for patching that. I'm happy with your fix.

No problem! That's pushed.





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

end of thread, other threads:[~2017-12-18 18:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-17  1:35 bug#29749: 27.0.50; Fix header value extraction in Gnus registry Eric Abrahamsen
2017-12-18  0:35 ` Ted Zlatanov
2017-12-18 18:12   ` 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.