Subject: bug#32941: get_bug_log SOAP operation truncates message

From: Michael Albinus <[email-masked]>
Date: Fri, 05 Oct 2018 12:31:54 +0200

Arun Isaac <[email-masked]> writes:

Hi Arun,

> The get_bug_log operation of the SOAP API truncates some messages. For
> example, look at the 4th message (indexing from 0) in bug 25235. In the
> web interface, https://debbugs.gnu.org/cgi/bugreport.cgi?bug=25235#17 ,
> one can see that the message has 2 parts, but the get_bug_log SOAP
> operation only returns the first part.

I can confirm this. Debugging the Debbugs/SOAP software, it looks like
the Perl function Debbugs::MIME::getmailbody is responsible. In case of
multipart messages, it contains the following code:

--8<---------------cut here---------------start------------->8---
	# For other multipart types, we just pretend they're
	# multipart/mixed and run through in order.
	for my $part ($entity->parts) {
	    my $ret = getmailbody($part);
	    return $ret if $ret;
--8<---------------cut here---------------end--------------->8---

That is, the first non-empty message part is returned. That seems to be
not sufficient.

Debbugs::MIME::getmailbody is called in function Debbugs::MIME::parse,
which uses MIME::Parser internally. Interestingly, it has also fallback
code in case MIME::Parser fails to work. If I disable MIME::Parser
there, forcing the run the fallback code, the result looks as it should,
including all MIME parts. In fact, the 'body' part is just the email
body.

I suppose that the current behaviour is due to the fact, that there were
plans to return the other MIME parts as 'attachments'. This is not
implemented (yet), see the code of Debbugs::SOAP::get_bug_log.

Displaying the bug messages via the web server, does not use this
function. Therefore, all attachments are visible.

Calling get_bug_log(25235) via Debbugs/SOAP exposes also another
error. It returns the HTTP header lines

--8<---------------cut here---------------start------------->8---
HTTP/1.1 200 OK
Date: Fri, 05 Oct 2018 09:29:12 GMT
Server: Apache
SOAPServer: SOAP::Lite/Perl/1.11
Strict-Transport-Security: max-age=63072000
Content-Length: 47549
X-Content-Type-Options: nosniff
X-Frame-Options: sameorigin
X-XSS-Protection: 1; mode=block
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: multipart/related; type="text/xml"; start="<main_envelope>"; boundary="=-=-="
--8<---------------cut here---------------end--------------->8---

The Content-Type: line is wrong, it should be just

--8<---------------cut here---------------start------------->8---
Content-Type: text/xml; charset=utf-8
--8<---------------cut here---------------end--------------->8---

Due to this wrong Content-Type: header, my Debbugs/SOAP client
(debbugs.el from GNU Emacs) refuses to work for get_bug_log(25235).

I've reported this to the Debian folks as
<https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=910360>.

Best regards, Michael.