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

Andras Mantia amantia at kde.org
Sun Jul 12 21:03:55 BST 2009


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

(Updated 2009-07-12 20:03:55.522849)


Review request for KDE PIM.


Changes
-------

Here is a different solution: KMime::Content/Message is changes so assemble() touches the headers ONLY if there was a change in them. Obviously, this makes assemble() slower. Tested with mailreader that message integrity is kept, and updated the kmime_content test to actually test if the assemble() changes the message and test also that it still works when the message is assembled from scratch.


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 (updated)
-----

  /branches/work/akonadi-ports/kdepimlibs/kmime/kmime_content.h 994094 
  /branches/work/akonadi-ports/kdepimlibs/kmime/kmime_content.cpp 994094 
  /branches/work/akonadi-ports/kdepimlibs/kmime/kmime_message.cpp 994094 
  /branches/work/akonadi-ports/kdepimlibs/kmime/tests/kmime_content_test.cpp 994094 

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