PHP Classes

Bug: Double encoding of UTF encoded 'encoded-word's

Recommend this page to a friend!

      PHP MIME Email Message Parser  >  All threads  >  Bug: Double encoding of UTF encoded...  >  (Un) Subscribe thread alerts  
Subject:Bug: Double encoding of UTF encoded...
Summary:Subject header decoded wrong
Messages:5
Author:abc def
Date:2014-08-29 20:35:13
 

  1. Bug: Double encoding of UTF encoded...   Reply   Report abuse  
Picture of abc def abc def - 2014-08-29 20:35:13
Subject: Test =?UTF-8?B?w7xiZXJzIG5ldWUgU3lzdGVt?=
should be decoded as "Test übers neue System"

However, it is decoded as "Test übers neue System", i.e. a UTF-8 string byte-encoded as UTF-8. This is one encoding step too many.

  2. Re: Bug: Double encoding of UTF encoded...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2014-08-30 03:26:08 - In reply to message 1 from abc def
Couldn't that be because you are displaying the decoded text in a Web page that is not setting the character encoding to UTF-8?

  3. Re: Bug: Double encoding of UTF encoded...   Reply   Report abuse  
Picture of abc def abc def - 2014-08-30 05:32:23 - In reply to message 2 from Manuel Lemos
No. I checked that before, of course.

I have here two testmails side by side, both with umlauts.

1. Subject: =?ISO-8859-1?Q?t=F6stmail?=
2. Subject: Test =?UTF-8?B?w7xiZXJzIG5ldWUgU3lzdGVt?=

They cannot made to display correctly on the same page. While the first one is displayed correctly on a UTF8 page, the second one is encoded one time too many.

  4. Re: Bug: Double encoding of UTF encoded...   Reply   Report abuse  
Picture of abc def abc def - 2014-08-30 07:55:25 - In reply to message 3 from abc def
Okay, one UTF8 encoding was in my output shipping code. However, this does not change the issue that the two subject lines (both with umlauts, but encoded differently) would not fit into the same display code. Isn't DecodedHeaders meant to decode all headers to the same normalized encoding?

I now ignore DecodedHeaders and use PHP's imap_utf8 on Header, which works as expected.

  5. Re: Bug: Double encoding of UTF encoded...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2014-08-31 09:39:13 - In reply to message 4 from abc def
No because your application may choose to convert to an encoding that class may not be able to convert within your PHP environment. For instance you used a function of the IMAP extension that may be removed from PHp in the future.

The way the class works now, is that it tells the encoding the message header is using. Then you can use other PHP functions in your PHP application if it is necessary to convert the text or not.