Bug 201017

Summary: KMail cannot correctly display subjects with UTF-8 characters encoded in quoted-printable fomat
Product: [Applications] kmail Reporter: gambas <g4mba5>
Component: generalAssignee: kdepim bugs <kdepim-bugs>
Status: RESOLVED NOT A BUG    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Mandriva RPMs   
OS: Unspecified   
Latest Commit: Version Fixed In:

Description gambas 2009-07-21 18:33:10 UTC
Version:            (using KDE 4.2.4)
Installed from:    Mandriva RPMs

The SMTP standard specified how to specify the charset and the encoding of the "Subject:" header in a mail.

For example, here is a mail whose subject has UTF-8 characters encoded in quoted-printable format:

Date: Sun, 19 Jul 2009 23:00:07 +0200
From: <gambas@users.sf.net>
Subject: =?utf-8?q?Test_du_composant_SMTP_de_Gambas_-_Des_caract=C3=A8r?=
 =?utf-8?q?es_bizarres_?_=E2=82=AC=C2=A4=C2=A7=C3=A6=C5=93=C3=9F=C3=B0?=
 =?utf-8?q?=C4=91=C2=BB=E2=80=9C=E2=80=9D=C2=AB_-_Test_d'un_sujet_en_ut?=
 =?utf-8?q?f-8_et_qui_est_trop_long,_enfin_qui_ne_devrait_pas_tenir_sur?=
 =?utf-8?q?_une_seule_ligne._Est-ce_que_la_troncature_=C3=A0_78_caract?=
 =?utf-8?q?=C3=A8res_est_respect=C3=A9e_??=

KMail on KDE 3.5 and gmail.com perfectly displays that subject. But KMail on KDE 4.2.4 displays that:

Test du composant SMTP de Gambas - Des caractèr =?utf-8?q?es_bizarres_?_=E2=82=AC=C2=A4=C2=A7=C3=A6=C5=93=C3=9F=C3=B0?= 𻓔« - Test d'un sujet en utf-8 et qui est trop long, enfin qui ne devrait pas tenir sur une seule ligne. Est-ce que la troncature à 78 caract =?utf-8?q?=C3=A8res_est_respect=C3=A9e_??=
Comment 1 Thomas McGuire 2009-07-25 17:31:38 UTC
Sorry, but the example you have given is invalid.

According to RFC 2047, section 4.2. 'The "Q" encoding', part (3), it is not allowed to represent the '?' as itself.

This means
=?utf-8?q?es_bizarres_?_[...]
should be
=?utf-8?q?es_bizarres_=3F_[...]

File a bug report against the mail client that produced this message.
Comment 2 Thomas McGuire 2009-07-25 19:05:49 UTC
SVN commit 1002322 by tmcguire:

Be more robust against invalid encoded strings that have a stray '?' in them
Glad we have unit tests here, otherwise I would have introduced many regressions here.

CCBUG: 201017


 M  +17 -14    kmime_header_parsing.cpp  
 M  +6 -6      kmime_warning.h  
 M  +32 -0     tests/headertest.cpp  
 M  +3 -0      tests/headertest.h  
 M  +3 -0      tests/rfc2047test.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1002322
Comment 3 gambas 2009-07-25 19:23:37 UTC
You are right, this is my fault, I didn't read the RFC carefully enough when I wrote my quoted routine. I was thinking KMail was false because KMail/KDE3 and GMail were more tolerant! Shame on me :-)