imaginashaun / php-imap

Automatically exported from code.google.com/p/php-imap
GNU Lesser General Public License v3.0
0 stars 0 forks source link

3D charset #2

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
imap_fetchstructure seems to sometimes give the following format with a weird 
charset "3D".

[1] => stdClass Object
                (
                    [type] => 0
                    [encoding] => 4
                    [ifsubtype] => 1
                    [subtype] => HTML
                    [ifdescription] => 0
                    [ifid] => 0
                    [lines] => 26
                    [bytes] => 888
                    [ifdisposition] => 0
                    [ifdparameters] => 0
                    [ifparameters] => 1
                    [parameters] => Array
                        (
                            [0] => stdClass Object
                                (
                                    [attribute] => charset
                                    [value] => 3D
                                )

                        )

                )

This use case needs to be handled in order to not cause an exception for 
mb_string conversion.

Original issue reported on code.google.com by m...@roterman.com on 10 May 2011 at 6:36

GoogleCodeExporter commented 9 years ago
Fixed by changing:

if(!empty($params['charset'])) {

to

if(!empty($params['charset']) && mb_encoding_aliases($params['charset'])) {

Thank you for report!!!

Original comment by barbushin on 10 May 2011 at 7:09

GoogleCodeExporter commented 9 years ago
Thanks for the quick response but I get this now:

ErrorException [ Warning ]: mb_encoding_aliases(): Unknown encoding "3D"

Original comment by m...@roterman.com on 10 May 2011 at 7:21

GoogleCodeExporter commented 9 years ago
This seems to work:

if(!empty($params['charset'])) {
    $data = iconv($params['charset'], $this->serverEncoding, $data);
}

Original comment by m...@roterman.com on 10 May 2011 at 9:00

GoogleCodeExporter commented 9 years ago
Done. I have used your code :)

if(!empty($params['charset'])) {
    $data = iconv($params['charset'], $this->serverEncoding, $data);
}

Thank you!

Original comment by barbushin on 10 May 2011 at 10:28