Subject: bug#44307: 27.1; UTF-8 parts transferred as 8bit in multipart messages fail to decode

From: Alexandre Duret-Lutz <[email-masked]>
Date: Sun, 10 Jan 2021 15:48:35 +0100

Lars Ingebrigtsen <[email-masked]> writes:

> Alexandre Duret-Lutz <[email-masked]> writes:
>
>> Without (mm-disable-multibyte), the patch makes no difference to me.
>
> Darn.  The multibyteness here isn't what you should be looking at,
> though -- the " *nntpd*" buffer is multibyte, so it's all gonna end up
> in that state, anyway.  We just have to trick Emacs into not
> interpreting the files as text, but as bytes, which is what nnml's
> request-article function does, for instance.

The following patch seems to fix my rendering issues.

I don't understand why nnheader-insert-file-contents with 'raw-text
coding does not seem to work as desired on a multibyte-buffer.  I'll try
to play with it more.

This patch has the potential side effect of leaving to-buffer as
multibyte even if it was initially unibyte.  I don't know if this could
be an issue.  You seem to suggest those buffer are meant to be multibyte
anyway.

You've mentioned the " *nntpd*" buffer, but in make case this code seems
to be always using to-buffer ("*Article nnmaildir+gmail:Inbox*").  Not
sure if this matters.

diff --git a/lisp/gnus/nnmaildir.el b/lisp/gnus/nnmaildir.el
index e4fd976742..ca2b0e1295 100644
--- a/lisp/gnus/nnmaildir.el
+++ b/lisp/gnus/nnmaildir.el
@@ -1351,7 +1351,10 @@ nnmaildir-request-article
 	(throw 'return nil))
       (with-current-buffer (or to-buffer nntp-server-buffer)
 	(erase-buffer)
-	(nnheader-insert-file-contents nnmaildir-article-file-name))
+	(mm-disable-multibyte)
+	(let ((coding-system-for-read mm-text-coding-system))
+	  (nnheader-insert-file-contents nnmaildir-article-file-name))
+	(mm-enable-multibyte))
       (cons gname num-msgid))))
 
 (defun nnmaildir-request-post (&optional _server)

-- 
Alexandre Duret-Lutz