Skip to content

Conversation

@pH4Lk0n
Copy link

@pH4Lk0n pH4Lk0n commented Aug 21, 2021

I've found a bug in getContents() when part is encoded with quoted-printable.

When calling Horde_Mime_Part::parseMessage() at the beginning all EOL characters are converted to CR instead of CRLF but unfortunately it messes quoted-printable encoding which required CRLF.
As it states in comments CR is required internally so I've added additional backwards conversion only to stream contents of parts encoded to quoted-printable.
When using Horde_Mime_Part::getRawPartText() which for some reason uses CRLF I can manually decode quoted-printable just fine without any other conversions.

I've run several test and it's working fine.

Simple test case:

$part = Horde_Mime_Part::parseMessage(file_get_contents('test.eml'));
$p = $part['1.2'];

$stream = $p->getContents([
    'stream' => true
]);
rewind($stream);
header('Content-Type: image/png');
fpassthru($stream);
fclose($stream);

Assuming that test.eml is test email message and in 1.2 part is image encoded with quoted-printable.

@yunosh
Copy link
Member

yunosh commented Jan 12, 2022

I don't see this happening: https://3v4l.org/IfOZ3

@yunosh
Copy link
Member

yunosh commented Jan 12, 2022

Oh, and binary data is not intended to be quoted-printable encoded.

ChristophWurst added a commit to ChristophWurst/Mime that referenced this pull request May 23, 2022
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>

Co-authored-by: Kieran <kieran.brahney@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants