[imp] Subject encoding issue

qmail at top-consulting.net qmail at top-consulting.net
Sat May 15 16:01:21 UTC 2010


The issue of the '?' characters has now also been solved. Not sure if  
it's just our systems or everyone out there that has this problem but  
we made the following change in imp/mailbox.php

changed:
$msg['subject'] = $imp_ui->getSubject($ob->subject);

to:
$msg['subject'] = utf8_encode($imp_ui->getSubject($ob->subject));

Doing this, also no longer requires the modification to  
NLS::getCharset() I mentioned earlier since the subject effectively is  
UTF8 now and the function works properly.

Cheers

I guess it could be done in one line as well
Quoting qmail at top-consulting.net:

> For issue #2, I found the following by printing the Ascii codes for  
> each letter of the troubled words in the subject.
>
> Taking for example the word: Académico
>
> When it's being displayed properly, it's made up of the following codes:
>
> 65 - A
> 99 - c
> 97 - a
> 100 - d
> 195 - ?
> 169 - ?
> 109 - m
> 105 - i
> 99 - c
> 111 - o
>
> When it's showing incorrectly, it's made up of:
>
> 65 - A
> 99 - c
> 97 - a
> 100 - d
> 233 - ?
> 109 - m
> 105 - i
> 99 - c
> 111 - o
>
> I got these values by running the following code:
>
> for ($x=0;$x<strlen($msg['subject']);$x++) {
>                 print ord(substr($msg['subject'],$x,1))." -   
> ".substr($msg['subject'],$x,1)."<br>";
>         }
> In one example the é is made from two codes ( 195/169 ) and displays  
> properly while the second time around it's made from only one code (  
> 233 ) and shows the question mark.
>
> What gives ?
>
> Quoting qmail at top-consulting.net:
>
>> I'm still unsure as to what issue #1 is and it still remains but I  
>> did make headway with issue #2.
>>
>> I tracked down the problem to Horde/Text.php in the function  
>> htmlSpaces(). More precisely, this line:
>>
>> $charset = NLS::getCharset();
>>
>> NLS::getCharset always returned UTF-8 even though my subject was  
>> encoded in ISO-8859-1. Further down, this line was effectively  
>> emptying out my subject line whenever $charset was set to UTF-8:
>>
>> $text = @htmlspecialchars($text, ENT_COMPAT, $charset);
>>
>> For now, I changed $charset = NLS::getCharset(); with $charset =  
>> NLS::getCharset(TRUE);  which works because now the charset is  
>> returned as ISO-8859-1
>>
>> Is this a limitation of the htmlspecialchars() function ?
>>
>> However, I still have issue #1 present where it shows '?' instead  
>> of the actual character.
>>
>> Quoting qmail at top-consulting.net:
>>
>>> I have two problems, not sure if they are a bug on my server or  
>>> maybe a bug within IMP.
>>>
>>> I am using the latest Horde Webmail distribution:
>>>
>>> Horde: 3.3.8
>>> IMP: 4.3.7
>>> c-client library: 2007e
>>> libiconv: 1.13.1
>>> Dovecot IMAP: 1.2.10
>>>
>>> Issue #1.
>>>
>>> IMP can't display characters from a different charset in the  
>>> subject and instead displays a ? instead of the character. In the  
>>> body of the message the subject displays just fine.
>>>
>>> I enabled the rawlog option in Dovecot to see the actual IMAP  
>>> conversation between IMP and IMAP. When it just gets the message  
>>> index, for that particular message I see:
>>>
>>> * 4 FETCH (INTERNALDATE "11-May-2010 20:22:31 -0400" RFC822.SIZE  
>>> 2357 FLAGS (\Seen) ENVELOPE ("Tue, 11 May 2010 17:53:34 -0600" {86}
>>>
>>> IT-F01 Solicitud de acción de Infraestructura Tecnológica. Otro  
>>> según detalle adjunto.
>>>
>>> Which is perfectly fine. However, in Webmail I see the subject as being:
>>> IT-F01 Solicitud de acci?n de Infraestructura Tecnol?gica. Otro  
>>> seg?n detalle adjunto.
>>>
>>>
>>> Issue #2.
>>>
>>> IMP shows no subject line at all for messages that contain  
>>> subjects defined encoded in ISO-8859-1. On the server the subject  
>>> starts like this:
>>>
>>> =?iso-8859-1?Q?FW:_
>>>
>>> What could this be ?
>>>
>>> Thank you!
>>>
>>> -- 
>>> IMP mailing list - Join the hunt: http://horde.org/bounties/#imp
>>> Frequently Asked Questions: http://horde.org/faq/
>>> To unsubscribe, mail: imp-unsubscribe at lists.horde.org
>>>
>>
>>
>>
>> -- 
>> IMP mailing list - Join the hunt: http://horde.org/bounties/#imp
>> Frequently Asked Questions: http://horde.org/faq/
>> To unsubscribe, mail: imp-unsubscribe at lists.horde.org
>>
>
>
>
> -- 
> IMP mailing list - Join the hunt: http://horde.org/bounties/#imp
> Frequently Asked Questions: http://horde.org/faq/
> To unsubscribe, mail: imp-unsubscribe at lists.horde.org
>





More information about the imp mailing list