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

Fix issue 126 for attachment #198

Merged
merged 5 commits into from Apr 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/Parser.php
Expand Up @@ -469,9 +469,6 @@ public function getInlineParts($type = 'text')
$headers = $this->getPart('headers', $part);
$encodingType = array_key_exists('content-transfer-encoding', $headers) ?
$headers['content-transfer-encoding'] : '';
if (is_array($encodingType)) {
$encodingType = $encodingType[0];
}
$undecoded_body = $this->decodeContentTransfer($this->getPartBody($part), $encodingType);
$inline_parts[] = $this->charset->decodeCharset($undecoded_body, $this->getPartCharset($part));
}
Expand Down Expand Up @@ -665,6 +662,10 @@ protected function getAttachmentStream(&$part)
*/
protected function decodeContentTransfer($encodedString, $encodingType)
{
if (is_array($encodingType)) {
$encodingType = $encodingType[0];
}

$encodingType = strtolower($encodingType);
if ($encodingType == 'base64') {
return base64_decode($encodedString);
Expand Down
1 change: 1 addition & 0 deletions tests/ParserTest.php
Expand Up @@ -167,6 +167,7 @@ public function testMultipleContentTransferEncodingHeader()
$Parser = new Parser();
$Parser->setText(file_get_contents($file));
$Parser->getMessageBody('text');
$Parser->getAttachments();
}

public function testCreatingMoreThanOneInstanceOfParser()
Expand Down
15 changes: 15 additions & 0 deletions tests/mails/issue126
Expand Up @@ -16,9 +16,24 @@ Importance: Normal
X-Mailer: Microsoft Windows Live Mail 16.4.3508.205
X-MimeOLE: Produced By Microsoft MimeOLE V16.4.3508.205
Content-Transfer-Encoding: quoted-printable
Content-Type: multipart/mixed;
boundary="_003_7B2F0B047286488B990BD2EE3759554Dcompanykoreacokr_"

Hey;)
how so? It's Maria
I'm very ripe person and presently look up goodly Man, Hope You want to see me! response me, I can send You my picture, have a good day


--_003_7B2F0B047286488B990BD2EE3759554Dcompanykoreacokr_
Content-Type: text/plain; name="ATT00001.txt"
Content-Description: ATT00001.txt
Content-Disposition: attachment; filename="ATT00001.txt"; size=25;
creation-date="Mon, 20 Oct 2014 07:15:27 GMT";
modification-date="Mon, 20 Oct 2014 07:15:27 GMT"
Content-ID: <57BAB4E7BA79CB40B41CE0993FA444D5@company.com>
Content-Transfer-Encoding: base64
Content-Transfer-Encoding: base64

DQoNCg0Kc2VudCBmcm9tIG15IGlQaG9uZQ==

--_003_7B2F0B047286488B990BD2EE3759554Dcompanykoreacokr_--