Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Email class sometimes breaks multibyte subject #1498

Closed
takyana opened this Issue · 3 comments

2 participants

@takyana

The subject function of Email class sometimes breaks multibyte subject by splitting it at middle of a single multibyte character.

To regenerate this issue, placing the following code in the controller folder (file encoding should be UTF-8).

<?php
class Emailtest extends CI_Controller {
    public function index()
    {
        $this->load->library('email');
        $this->email->subject('これは日本語のテストです');
        var_dump($this->email->_headers);
    }
}

Then access to it and you will see the following result.

array(1) { ["Subject"]=> string(134) "=?utf-8?Q?=e3=81=93=e3=82=8c=e3=81=af=e6=97=a5=e6=9c=ac=e8=aa=9e=e3=81?= =?utf-8?Q?=ae=e3=83=86=e3=82=b9=e3=83=88=e3=81=a7=e3=81=99?=" } 

3 bytes "=e3=81=ae" around the second "=?utf-8?Q?" string, should not be splitted since these 3 byte combination means a single Japanese character.

As long as I tested, Thunderbird and Apple Mail fail to display this encoded subject.

The easiest fix is to use mb_encode_mimeheader function instead of _prep_q_encoding.
According to the PHP manual, mb_encode_mimeheader folds the line into 74 characters.

@narfbg
Owner

See #1409.

@narfbg narfbg closed this
@takyana

Before posting this issue, I read #1409.
#1409 seems different case, which is about how to correctly encode single line subject.

@narfbg
Owner

The "fix" might not be the same, but otherwise it's no different.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.