[Kde-pim] Review Request: Keep the message integrity in akonadi

Thomas McGuire mcguire at kde.org
Sun Jul 12 17:41:34 BST 2009


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://reviewboard.kde.org/r/988/#review1555
-----------------------------------------------------------

Ship it!



This looks like it will fail  when the KMime message is created with something more complicated than setContent(). E.g. if you use setHead, setData and maybe something like setSubject, the message needs to be assembled first before it is OK to call encodedContent() (which is called in the serialiher).

I guess it is impossible to make assemble() preserve the data, right? I don't know the internals, but I guess internally KMime stores the data in a way that the it can later not be reassembled 100% (think of header folding and whitespace that can occur at abitary places).

So looks like this patch has to go in, and we have to make a convention that messages passed into the payload have to be assembled already (and in case of calling setContent(), they are assembled). I don't like that much, but seems we have to do this that way.

- Thomas


On 2009-07-11 08:38:56, Andras Mantia wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://reviewboard.kde.org/r/988/
> -----------------------------------------------------------
> 
> (Updated 2009-07-11 08:38:56)
> 
> 
> Review request for KDE PIM.
> 
> 
> Summary
> -------
> 
> Currently when payloadData() is requested for a KMime::Message, the returned data is not *exactly* the same as the one that was stored. This breaks signature verfications (and probably encryption as well). The root of the problem is KMime::Content::assemble() that calls assembleHeaders() that recreates the header string from the header information. I see no reason to call assemble() for a message that was just retrieved from the database. With this change, the returned header matches the stored one.
> A simple testcas looks like this:
> 
> //data is the message as text, expectedheader is a header from a sub content, not the newline between text/plain and charset
>   QByteArray expectedHeader = "Content-Type: text/plain;\n\
>   charset=\"us-ascii\"\n\
> Content-Transfer-Encoding: 7bit\n";
> 
>   KMime::Message *message = new KMime::Message;
>   message->setContent( data );
>   message->parse();
>   QCOMPARE(message->contents().at(0)->head(), expectedHeader); /passes
>   i.setPayload( MessagePtr( message ) );
>   QVERIFY( i.hasPayload<MessagePtr>() ); //passes
>   qDebug() << i.payloadData(); //THIS IS THE IMPORTANT LINE!
>   MessagePtr readMessage = i.payload<MessagePtr>();
>   QCOMPARE(readMessage->contents().at(0)->head(), expectedHeader); //passes if the payloadData() line is disabled, fails otherwise
> 
> 
> Diffs
> -----
> 
>   /trunk/KDE/kdepim/akonadi/plugins/akonadi_serializer_mail.cpp 994530 
> 
> Diff: http://reviewboard.kde.org/r/988/diff
> 
> 
> Testing
> -------
> 
> Tested with mailreader and the above testcase, that I added to kdepimlibs/akonadi/test/itemtest.cpp (not sure if it belongs there).
> 
> 
> Thanks,
> 
> Andras
> 
>

_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/



More information about the kde-pim mailing list