GNU bug report logs - #79376
[PATCH] [WIP] Fix mm multibyte

Previous Next

Package: emacs;

Reported by: Manuel Giraud <manuel <at> ledu-giraud.fr>

Date: Wed, 3 Sep 2025 09:34:02 UTC

Severity: normal

Tags: patch

Full log


Message #11 received at 79376 <at> debbugs.gnu.org (full text, mbox):

From: Manuel Giraud <manuel <at> ledu-giraud.fr>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: larsi <at> gnus.org, morioka <at> jaist.ac.jp, 79376 <at> debbugs.gnu.org
Subject: Re: bug#79376: [PATCH] [WIP] Fix mm multibyte
Date: Wed, 03 Sep 2025 15:53:14 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

>> Cc: Lars Magne Ingebrigtsen <larsi <at> gnus.org>,
>>  MORIOKA Tomohiko <morioka <at> jaist.ac.jp>
>> From: Manuel Giraud <manuel <at> ledu-giraud.fr>
>> Date: Wed, 03 Sep 2025 11:33:33 +0200
>> 
>> I'm trying to fix an issue in Gnus where some Atom sources (namely
>> planet.emacslife.com/atom.xml, here) are not rendered correctly.
>> 
>> This seems to be related to multibyte/unibyte buffer.  Here is a minimal
>> exemple to reproduce what I see:
>> 
>> --8<---------------cut here---------------start------------->8---
>> (defun my/gen-handle ()
>>   (with-current-buffer (get-buffer-create " foo")
>>     (erase-buffer)
>>     (insert "’…")
>>     (list (current-buffer) '("text/html"))))
>> 
>> (defun my/test ()
>>   (let ((handle (my/gen-handle)))
>>     (mm-with-part handle
>>       (buffer-string))))
>> --8<---------------cut here---------------end--------------->8---
>> 
>> When evaluating (my/test), see that the buffer string content does not
>> have the correct characters.
>
> Hmm...  I'm not familiar with this code, but the comment in
> mm-with-part says:
>
>   ;; The handle-buffer's content is a sequence of bytes, not a sequence of
>   ;; chars, so the buffer should be unibyte.  It may happen that the
>   ;; handle-buffer is multibyte for some reason, in which case now is a good
>   ;; time to adjust it, since we know at this point that it should
>   ;; be unibyte.
>
> But your test case inserts a multibyte string into the buffer, so
> aren't you violating what this macro expects and should handle?

Yes, I've seen this comment and I do think that I'm violating what is
expected here… but then so does `mm-shr' (in my example trying to read
"planet.emacslife.com/atom.xml").

> And also, is a call to buffer-string something that this macro's body
> is useful for?

In mm-decode.el:1903, there is the following code:

(decode-coding-string (buffer-string) coding)

> Apologies if I'm not making sense.

No, I think you're perfectly on point.
-- 
Manuel Giraud




This bug report was last modified today.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.