Subject: Re: bug#64454: 30.0.50; In-Reply-To header obsolete content

From: Andrew Cohen <[email-masked]>
Date: Tue, 04 Feb 2025 09:50:55 +0800

I fixed this in my tree but never got around to pushing the result. I'll
push the following unless there are changes that are needed.

Best,
Andy

da900f025e9ed5e8d0e5aa9fb6bf9f5d54436c6c
Author:     Andrew G Cohen <[email-masked]>
AuthorDate: Wed Jul 5 15:21:16 2023 +0800
Commit:     Andrew G Cohen <[email-masked]>
CommitDate: Tue Feb 4 09:45:29 2025 +0800

Parent:     2dc8c54341e Fix crashes on XI devices being disabled (bug#75870)
Merged:     master
Contained:  feature/igc
Follows:    emacs-29.1.90 (176367)

Don't use obsolete In-Reply-To header format in messages

When creating a new message, message-send-mail uses an obsolete format
for the In-Reply-To header that includes additional information about
the originating message.  This patch changes the default to use the
rfc5322 approved format, but allow the obsolete format through a
defcustom.

* lisp/gnus/message.el (message-make-in-reply-to): Return only the
message-id of the originating message (the default) unless the new
custom variable message-header-use-obsolete-in-reply-to is non-nil.
* doc/misc/message.texi: Document the new custom variable
message-header-use-obsolete-in-reply-to.

2 files changed, 44 insertions(+), 28 deletions(-)
doc/misc/message.texi |  6 +++++
lisp/gnus/message.el  | 66 +++++++++++++++++++++++++++++----------------------

modified   doc/misc/message.texi
@@ -1791,6 +1791,12 @@ Message Headers
 @code{message-carefully-insert-headers} will not insert a @code{To}
 header when the message is already @code{CC}ed to the recipient.
 
+@item message-header-use-obsolete-in-reply-to
+@vindex message-header-use-obsolete-in-reply-to
+Use an obsolete form of the @code{In-Reply-To} header that includes a
+parenthetical phrase with details of the originating email following
+the message id.  The default is @code{nil}.
+
 @item message-syntax-checks
 @vindex message-syntax-checks
 Controls what syntax checks should not be performed on outgoing posts.
modified   lisp/gnus/message.el
@@ -113,6 +113,13 @@ message-faces
   :group 'message
   :group 'faces)
 
+(defcustom message-header-use-obsolete-in-reply-to nil
+  "Include extra information in the In-Reply-To header (this form
+has been obsolete since RFC 2822.)"
+  :group 'message-headers
+  :version "31.1"
+  :type 'boolean)
+
 (defcustom message-directory "~/Mail/"
   "Directory from which all other mail file variables are derived."
   :group 'message-various
@@ -5993,35 +6000,38 @@ message-make-in-reply-to
   "Return the In-Reply-To header for this message."
   (when message-reply-headers
     (let ((from (mail-header-from message-reply-headers))
-	  (date (mail-header-date message-reply-headers))
-	  (msg-id (mail-header-id message-reply-headers)))
+          (date (mail-header-date message-reply-headers))
+          (msg-id (mail-header-id message-reply-headers)))
       (when from
-	(let ((name (mail-extract-address-components from)))
-	  (concat
-	   msg-id (if msg-id " (")
-	   (if (car name)
-	       (if (string-match "[^[:ascii:]]" (car name))
-		   ;; Quote a string containing non-ASCII characters.
-		   ;; It will make the RFC2047 encoder cause an error
-		   ;; if there are special characters.
-                   (mm-with-multibyte-buffer
-                     (insert (car name))
-                     (goto-char (point-min))
-                     (while (search-forward "\"" nil t)
-                       (when (prog2
-                                 (backward-char)
-                                 (zerop (% (skip-chars-backward "\\\\") 2))
-                               (goto-char (match-beginning 0)))
-                         (insert "\\"))
-                       (forward-char))
-                     ;; Those quotes will be removed by the RFC2047 encoder.
-                     (concat "\"" (buffer-string) "\""))
-		 (car name))
-	     (nth 1 name))
-	   "'s message of \""
-	   (if (or (not date) (string= date ""))
-	       "(unknown date)" date)
-	   "\"" (if msg-id ")")))))))
+        (let ((name (mail-extract-address-components from)))
+          (concat
+           msg-id
+           (when message-header-use-obsolete-in-reply-to
+             (concat
+              (if msg-id " (")
+              (if (car name)
+                  (if (string-match "[^[:ascii:]]" (car name))
+                      ;; Quote a string containing non-ASCII characters.
+                      ;; It will make the RFC2047 encoder cause an error
+                      ;; if there are special characters.
+                      (mm-with-multibyte-buffer
+                        (insert (car name))
+                        (goto-char (point-min))
+                        (while (search-forward "\"" nil t)
+                          (when (prog2
+                                    (backward-char)
+                                    (zerop (% (skip-chars-backward "\\\\") 2))
+                                  (goto-char (match-beginning 0)))
+                            (insert "\\"))
+                          (forward-char))
+                        ;; Those quotes will be removed by the RFC2047 encoder.
+                        (concat "\"" (buffer-string) "\""))
+                    (car name))
+                (nth 1 name))
+              "'s message of \""
+              (if (or (not date) (string= date ""))
+                  "(unknown date)" date)
+              "\"" (if msg-id ")")))))))))
 
 (defun message-make-distribution ()
   "Make a Distribution header."

-- 
Andrew Cohen