Bug 189139 - decodeRFC2047String() doesn't parse stuff correctly
Summary: decodeRFC2047String() doesn't parse stuff correctly
Status: RESOLVED WORKSFORME
Alias: None
Product: kdepimlibs
Classification: Applications
Component: kmime (show other bugs)
Version: unspecified
Platform: Unlisted Binaries Linux
: NOR normal
Target Milestone: ---
Assignee: Tom Albers
URL:
Keywords: investigated, triaged
Depends on:
Blocks:
 
Reported: 2009-04-08 18:29 UTC by Jan Kundrát
Modified: 2018-10-21 05:06 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
decodeRFC2047String.patch (912 bytes, patch)
2009-04-08 18:29 UTC, Jan Kundrát
Details
decodeRFC2047String.patch (1.41 KB, patch)
2009-04-08 18:35 UTC, Jan Kundrát
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Kundrát 2009-04-08 18:29:06 UTC
Created attachment 32701 [details]
decodeRFC2047String.patch

I'm using a copy of trunk/KDE/kdepimlibs/kimap/rfccodecs.cpp in my private project. I've done only minimal modifications for it to integrate into a non-KDE environment.

The following code fails:

    QByteArray input = "From: =?UTF-8?B?UGF2ZWwgS29sw6HFmQ==?= <foo@bar>";
    qDebug() << input << KIMAP::decodeRFC2047String( input );
    input = "From: =?UTF-8?B?SmFuIEt1bmRyw6F0?= <jkt@gentoo.org>";
    qDebug() << input << KIMAP::decodeRFC2047String( input );
    input = "From: =?ISO-8859-1?Q?Jan_Kundr=E1t?= <kundratj@fzu.cz>";
    qDebug() << input << KIMAP::decodeRFC2047String( input );
    input = "Subject: =?utf-8?b?YmzDqXNtcnQgxJvFocSNxZnFvsO9w6HDrcOpIOygoO2IrOyXkOyEnA==?=\n"
 "=?utf-8?b?IOyekOuwlOulvCDsgqzsmqntlZjripQg6rKD7JeQIOuMgO2VnA==?=\n"
 "=?utf-8?b?IOyCrOyaqeyekOyZgCDqsJzrsJzsnpDrpbwg7JyE7ZWc?=\n"
 "=?utf-8?b?IOyngOy5qOyEnA==?=";
    qDebug() << input << KIMAP::decodeRFC2047String( input );

What I got with version from KDE:

"From: =?UTF-8?B?UGF2ZWwgS29sw6HFmQ==?= <foo@bar>" "From:  <foo@bar>"
"From: =?UTF-8?B?SmFuIEt1bmRyw6F0?= <jkt@gentoo.org>" "From:  <jkt@gentoo.org>"
"From: =?ISO-8859-1?Q?Jan_Kundr=E1t?= <kundratj@fzu.cz>" "From:  <kundratj@fzu.cz>"
"Subject: =?utf-8?b?YmzDqXNtcnQgxJvFocSNxZnFvsO9w6HDrcOpIOygoO2IrOyXkOyEnA==?=
=?utf-8?b?IOyekOuwlOulvCDsgqzsmqntlZjripQg6rKD7JeQIOuMgO2VnA==?=
=?utf-8?b?IOyCrOyaqeyekOyZgCDqsJzrsJzsnpDrpbwg7JyE7ZWc?=
=?utf-8?b?IOyngOy5qOyEnA==?=" "Subject:


"


What was the correct result (a lot of funny Unicode characters follows):

"From: =?UTF-8?B?UGF2ZWwgS29sw6HFmQ==?= <foo@bar>" "From: Pavel Kolář <foo@bar>"
"From: =?UTF-8?B?SmFuIEt1bmRyw6F0?= <jkt@gentoo.org>" "From: Jan Kundrát <jkt@gentoo.org>"
"From: =?ISO-8859-1?Q?Jan_Kundr=E1t?= <kundratj@fzu.cz>" "From: Jan Kundrát <kundratj@fzu.cz>"
"Subject: =?utf-8?b?YmzDqXNtcnQgxJvFocSNxZnFvsO9w6HDrcOpIOygoO2IrOyXkOyEnA==?=
=?utf-8?b?IOyekOuwlOulvCDsgqzsmqntlZjripQg6rKD7JeQIOuMgO2VnA==?=
=?utf-8?b?IOyCrOyaqeyekOyZgCDqsJzrsJzsnpDrpbwg7JyE7ZWc?=
=?utf-8?b?IOyngOy5qOyEnA==?=" "Subject: blésmrt ěščřžýáíé 젠투에서
 자바를 사용하는 것에 대한
 사용자와 개발자를 위한
 지침서"

These data are taken from read-world mails (some of them were in fact generated by KMail). The attached patch fixes the problem.
Comment 1 Jan Kundrát 2009-04-08 18:35:22 UTC
Created attachment 32702 [details]
decodeRFC2047String.patch

Sorry, the attached patch is not correct (the end result is OK, but due to an error on my side, the diff itself isn't against pure upstream version). Attaching a new one.
Comment 2 Tom Albers 2009-04-09 22:37:01 UTC
Hi Jan, 

Can you try the decoder provided by kdelibs?

http://api.kde.org/4.x-api/kdelibs-apidocs/kdecore/html/namespaceKCodecs.html#2ef0e4b98dad2a6fc90f4dc229f83daf

I think i should remove those classes from the kimap folder...

Can you confirm the one in kdelibs is okay?
Comment 3 Allen Winter 2009-06-07 03:06:32 UTC
Jan: ping

we'd really like to know if we should use your patch, or remove the kimap/rfccodecs version in favor of the kdelibs version.

Please advise.
Comment 4 Jan Kundrát 2009-06-08 01:35:21 UTC
Hi Allen/Tom, sorry for not responding earlier. Due to certain deadlines at school, I wasn't able to test the version from kdelibs yet. As of the correctness of the patch, well, current version of your code is broken. On the other hand, if nobody really uses it (as suggested by Tom's command), it could probably go away.

This report was done from a perspective of a programmer who just happened to come across your code and decided to include a copy of it in his own application (with a proper credit). I have no idea if the code in question is available through a public API or if it might affect any KDE application, so I'm not in the position to decide whether it should be fixed or abandoned.

If the code in kdelibs looks better (it does, at least on a quick glance -- no nasty char* modifying etc), it's wise to remove the old cruft.

Thanks for your time.
Comment 5 Andrew Crouthamel 2018-09-19 04:28:21 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least 15 days. Please provide the requested information as soon as possible and set the bug status as REPORTED. Due to regular bug tracker maintenance, if the bug is still in NEEDSINFO status with no change in 30 days the bug will be closed as RESOLVED > WORKSFORME due to lack of needed information.

For more information about our bug triaging procedures please read the wiki located here: https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please mark the bug as REPORTED so that the KDE team knows that the bug is ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 6 Andrew Crouthamel 2018-10-21 05:06:28 UTC
This bug has been in NEEDSINFO status with no change for at least
30 days. The bug is now closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

Thank you for helping us make KDE software even better for everyone!