Subject: bug#61041: 28.1; recipient-filename not set correctly in mml-insert-mime-headers

From: Abdul-Lateef Haji-Ali <[email-masked]>
Date: Tue, 24 Jan 2023 16:42:12 +0000

In the function `mml-insert-mime-headers`, the part contents (in `cont`) is tested for `recipient-filename` on mml.el:938
However, that logic is inside an if statement on non-nil `parameters` which is returned from `(mml-parameter-string cont mml-content-disposition-parameters)`

The result is that if `cont` does not contain any of the fields in `mml-content-disposition-parameters`, as is the case when the part has a buffer without a file-name. The recipient-filename is not include in `Content-Disposition`.

If this is unintended, as I suspect it is, it can be fixed with the following patch, for example:

------------------------------------------------------------
--- lisp/gnus/mml.el
+++ lisp/gnus/mml.el
@@ -924,22 +924,23 @@
       (insert "\n"))
     (when (setq id (cdr (assq 'id cont)))
       (insert "Content-ID: " id "\n"))
-    (setq parameters
-	  (mml-parameter-string
-	   cont mml-content-disposition-parameters))
-    (when (or (setq disposition (cdr (assq 'disposition cont)))
-	      parameters)
-      (insert "Content-Disposition: "
-	      (or disposition
-		  (mml-content-disposition type (cdr (assq 'filename cont)))))
-      (when parameters
-	(let ((cont (copy-sequence cont)))
-	  ;; Set the file name to what's specified by the user.
-	  (when-let ((recipient-filename (cdr (assq 'recipient-filename cont))))
-	    (setcdr cont
-		    (cons (cons 'filename recipient-filename)
-			  (cdr cont))))
-	  (mml-insert-parameter-string
+    (let ((cont cont))
+      (when-let ((recipient-filename (cdr (assq 'recipient-filename cont))))
+        ;; Set the file name to what's specified by the user.
+        (setq cont (copy-sequence cont))
+	(setcdr cont
+		(cons (cons 'filename recipient-filename)
+		      (cdr cont))))
+      (setq parameters
+	    (mml-parameter-string
+	     cont mml-content-disposition-parameters))
+      (when (or (setq disposition (cdr (assq 'disposition cont)))
+	        parameters)
+        (insert "Content-Disposition: "
+	        (or disposition
+		    (mml-content-disposition type (cdr (assq 'filename cont)))))
+        (when parameters
+          (mml-insert-parameter-string
 	   cont mml-content-disposition-parameters)))
       (insert "\n"))
     (unless (eq encoding '7bit)
------------------------------------------------------------

-- Al

________________________________
Heriot-Watt University was founded in 1821 and is a registered Scottish charity (SC000278).