Welcome Guest, Not a member yet? Register   Sign In
E-Mail with UTF encoded Subject - if longer then expected length => becomes garbled in gmail
#1

[eluser]Ki[/eluser]
Hi,
I dont want to yell "BUG!!!" just because I have encountered this unexpected behavior BUT I noticed that email subjects with non-english characters (cyrillic) end up showing as "=d0=97=d0=95=d0" when they are longer then a certain length.
I was able to fix it by making 2 modifications to Email Class -> function _prep_q_encoding
Modifications (2):
Code:
for ($i = 0, $length = strlen($str); $i < $length; $i++)
        {
            // Grab the next character
            $char = substr($str, $i, 1);
            $ascii = ord($char);

            // convert ALL non-printable ASCII characters and our specials
            if ($ascii < 32 OR $ascii > 126 OR in_array($char, $convert))
            {
commented out this =>        //$char = '='.dechex($ascii);
            }

            // handle regular spaces a bit more compactly than =20
            if ($ascii == 32)
            {
and commented out this =>    //$char = '_';
            }

            // If we're at the character limit, add the line to the output,
            // reset our temp variable, and keep on chuggin'
            if ((strlen($temp) + strlen($char)) >= $limit)
            {
                $output .= $temp.$this->crlf;
                $temp = '';
            }

            // Add the character to our temporary line
            $temp .= $char;
        }

Here are my headers
With 'bad' email subject:

Subject: =?utf-8?Q?Objava: =d0=97=d0=95=d0=9c=d0=af =d0=a1=d0=9c=d0=95=d0=9b=d0?=
=?utf-8?Q?=9d=d0=98=d0=a6=d0=90?=

With 'fixed' email subject:

Subject: =?utf-8?Q?Objava: ЗЕМЯ СМЕЛНИЦА?=

Can someone comment on this
Is this a bug?
May I have other issues by commenting out those sections of the class (mentioned above)?

Ki
#2

[eluser]Kromack[/eluser]
Same issue for me, thanks for the trick.
#3

[eluser]takasia[/eluser]
Thanks!
This really saved my time :-)

I commented out also this line:

$str = trim(preg_replace('/^(.*)$/m', ' =?'.$this->charset.'?Q?$1?=', $str));

After that, I got this:

Subject: MY_TEXT_IN_JAPANESE

instead of this:

Subject: =?utf-8?Q?MY_TEXT_IN_JAPANESE?=
#4

[eluser]Narf[/eluser]
How about this: https://gist.github.com/3891474

More info: https://github.com/EllisLab/CodeIgniter/...nt-9330713




Theme © iAndrew 2016 - Forum software by © MyBB