do not lose address headers when decrypting mail

Authored by mkoller on Mar 29 2020, 10:38 AM.



CryptoUtils::copyHeader uses a wrong function to copy the header data.
it uses fromUnicode(asUnicode), but kmime_headers.h states:
"It is not guaranteed that fromUnicodeString( asUnicodeString(), ... ) will return the original string."

I run into this bug where the From and To Headers contained data such as:
"some name (bla)" <mail@a.b>

but asUnicodeString() did not put quotes around "some name (bla)" so parsing did not work out and left the result empty.

This solves BUG #413022

Test Plan

decrypt a mail containing From/To headers in the form
"some name (bla)" <mail@a.b>

Diff Detail

R92 PIM: Common Mail Support
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.
mkoller created this revision.Mar 29 2020, 10:38 AM
Restricted Application added a project: KDE PIM. · View Herald TranscriptMar 29 2020, 10:38 AM
Restricted Application added a subscriber: kde-pim. · View Herald Transcript
mkoller requested review of this revision.Mar 29 2020, 10:38 AM
mkoller edited the summary of this revision. (Show Details)

is it possible to create an autotest for it ?

seriously ?
I'm pretty sure that creating a test for this 5 line function would take me more hours than to analyse the initial bug, and the numbers of codelines would pose more risk to introduce a bug in the test than in the function to test.
Instead of investing my time to create such a test, I'd rather try to fix another bug.

"seriously" yep . Creating a testcase avoiding to recreate a bug if a people modifies this code source without knowing why it was changed.

knauss added a subscriber: knauss.Mar 30 2020, 8:25 AM

I may can help to create a test case.

Okay it should not be that hard. We have already the mailcommon/src/filter/autotests/filteractiondecrypttest.* that reads mails from mailcommon/src/filter/autotests/gpgdata/. And there are normal mails inside it.

@mkoller so you can either modify the existing mails, that would trigger this bug or copy one mail triplet and modify the headers at the new triplet. Both solutions shouldn't take much time.

mkoller updated this revision to Diff 79300.Apr 4 2020, 2:28 PM

modified existing test to show actual bug

knauss accepted this revision.Apr 4 2020, 4:02 PM
This revision is now accepted and ready to land.Apr 4 2020, 4:02 PM
This revision was automatically updated to reflect the committed changes.