Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getContents() quoted-printable EOL patch #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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 <[email protected]>

Co-authored-by: Kieran <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants