After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 724702 - Content-Type header duplicated in parsed message
Content-Type header duplicated in parsed message
Status: RESOLVED FIXED
Product: gmime
Classification: Other
Component: general
2.6.x
Other Linux
: Normal normal
: ---
Assigned To: Jeffrey Stedfast
Jeffrey Stedfast
Depends on:
Blocks:
 
 
Reported: 2014-02-19 00:31 UTC by Charles Lindsay
Modified: 2014-02-19 14:43 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Charles Lindsay 2014-02-19 00:31:31 UTC
If you try to remove a header from a GMimeMessage that comes out of a GMimeParser, an extra and identical Content-Type header will be appended to the message.  It's possible that operations other than removing a header will also result in duplicate Content-Type headers, though I haven't worked on a test case for anything else.  See the following example, noting that the header being removed doesn't actually exist (and thus I'd expect the remove_header call to be a no-op):


#include <gmime/gmime.h>
#include <stdio.h>

static const char data[] = {
    "Date: Tue, 18 Feb 2014 18:18:08 -0800\r\n"
    "MIME-Version: 1.0\r\n"
    "Content-Type: multipart/alternative; boundary=asdf\r\n"
    "\r\n"
    "--asdf--\r\n"
};

int main(void) {
    g_mime_init(0);
    GMimeMessage *m = g_mime_parser_construct_message(
        g_mime_parser_new_with_stream(
            g_mime_stream_mem_new_with_buffer(data, sizeof(data) - 1)
        )
    );

    g_mime_object_remove_header((GMimeObject *) m, "nonexistant");

    printf("%s", g_mime_object_to_string((GMimeObject *) m));
    return 0;
}


When I run that program, I see:


Date: Tue, 18 Feb 2014 18:18:08 -0800
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary=asdf
Content-Type: multipart/alternative; boundary=asdf

--asdf--


I'd expect to see only one Content-Type header.  Tested in GMime master, revision 716e481.
Comment 1 Jeffrey Stedfast 2014-02-19 14:43:49 UTC
Fixed in git master and I made a 2.6.20 release with the fix included

Thanks for the bug report!