bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#25896: gnus-read-ephemeral-bug-group can modify message body


From: Katsumi Yamaoka
Subject: bug#25896: gnus-read-ephemeral-bug-group can modify message body
Date: Wed, 01 Mar 2017 14:23:07 +0900
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (i686-pc-cygwin)

On Tue, 28 Feb 2017 02:11:21 -0500, Glenn Morris wrote:
> emacs -Q -l gnus
> M-x gnus-read-ephemeral-emacs-bug-group RET 25891 RET:

> I noticed that the To: lines in the examples quoted in the message body
> (eg "To: Victor Lazzarini <Victor.Lazzarini AT nuim.ie>") are modified,
> by having 25891@debbugs added to them.

How about a diff below?  This version doesn't add the debbugs
address if it already exists in To: or Cc: field in a message
header, otherwise it adds the address to the To header, or adds
the To header along with the address if the To header is absent.
All are done in each narrowed message header of mbox data.

--- lisp/gnus/gnus-group.el~    2017-01-04 22:16:44.000000000 +0000
+++ lisp/gnus/gnus-group.el     2017-03-01 05:06:46.565658800 +0000
@@ -2464,14 +2464,33 @@
                     (file-exists-p file))
                (insert-file-contents file)
              (url-insert-file-contents (format mbox-url id)))))
-       (goto-char (point-min))
        ;; Add the debbugs address so that we can respond to reports easily.
-       (while (re-search-forward "^To: " nil t)
-         (end-of-line)
-         (insert (format ", %s@%s" (car ids)
-                         (replace-regexp-in-string
-                          "/.*$" ""
-                          (replace-regexp-in-string "^http://"; "" 
mbox-url)))))))
+       (let ((address
+              (format "%s@%s" (car ids)
+                      (replace-regexp-in-string
+                       "/.*$" ""
+                       (replace-regexp-in-string "^http://"; "" mbox-url)))))
+         (goto-char (point-min))
+         (while (re-search-forward (concat "^" message-unix-mail-delimiter)
+                                   nil t)
+           (narrow-to-region (point)
+                             (if (search-forward "\n\n" nil t)
+                                 (1- (point))
+                               (point-max)))
+           (unless (string-match (concat "\\(?:\\`\\|[ ,<]\\)"
+                                         (regexp-quote address)
+                                         "\\(?:\\'\\|[ ,>]\\)")
+                                 (concat (message-fetch-field "to") " "
+                                         (message-fetch-field "cc")))
+             (goto-char (point-min))
+             (if (re-search-forward "^To:" nil t)
+                 (progn
+                   (message-next-header)
+                   (skip-chars-backward "\t\n ")
+                   (insert ", " address))
+               (insert "To: " address "\n")))
+           (goto-char (point-max))
+           (widen)))))
     (gnus-group-read-ephemeral-group
      (format "nndoc+ephemeral:bug#%s"
             (mapconcat 'number-to-string ids ","))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]