javanile / php-imap2

PHP IMAP with OAUTH2
https://php-imap2.javanile.org/
GNU General Public License v3.0
54 stars 31 forks source link

extractPart encoding bug #10

Open cjwnz opened 2 years ago

cjwnz commented 2 years ago

The encoding flag returned by imap2_fetchstructure is wrong for encoded images. It is returning zero when the image is in fact base 64 encoded.

Ref: line #133 of BodyStructure.php

Please fix this asap. Thanks.

francescobianco commented 2 years ago

Hi @cjwnz , could You please send the email with problematic content on base64 to the following email address:

javanile.develop@gmail.com

I'll run test directly to the problematic email

cjwnz commented 2 years ago

Done. We also can't extract the mime_type the way it was working with original imap functions. Instead of 'image/png' we get 'ANSUhEUgAAANwAAAEeCAYAAADhDXuKAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA B3RJTUUH5gYHFis7wY5UqQAAIABJREFUeJzs' for example

Thanks

cjwnz commented 2 years ago

imap2_fetchmime is returning an encoded string instead of plain text where we expect to extract "Content-Type:"

francescobianco commented 2 years ago

Hi @cjwnz , could you please test our new version https://github.com/javanile/php-imap2/releases/tag/0.1.9

cjwnz commented 2 years ago

imap2_fetchmime has now been fixed - thank you! However, there is still an issue with imap2_fetchbody returning incorrect value (0) for encoding. See below.

Output of imap2_fetchmime:

Content-Type: image/png; name="boy.png"
Content-Description: boy.png
Content-Disposition: attachment; filename="boy.png"; size=92415;
creation-date="Thu, 15 Sep 2022 21:03:37 GMT";
modification-date="Thu, 15 Sep 2022 21:03:40 GMT"
Content-Transfer-Encoding: base64   <==== Data is Base 64 encoded

Output of imap2_fetchbody:

[type] => 0
[encoding] => 0    <==== Expecting value for ENCBASE64
[ifsubtype] => 1
[subtype] => png
[ifdescription] => 1
[description] => boy.png
[ifid] => 0
[lines] => 0
[bytes] => 126246
[ifdisposition] => 0
[ifdparameters] => 0
[ifparameters] => 1
[parameters] => Array
(
[0] => stdClass Object
(
[attribute] => name
[value] => boy.png
cjwnz commented 2 years ago

sorry correction above - bug is return value from imap2_fetchstructure, not imap2_fetchbody

dicode-nl commented 2 years ago

@cjwnz try my patch in PR https://github.com/javanile/php-imap2/pull/12