Skip to content

Commit

Permalink
Merge pull request #110 from magento-engcom/67-eliminate-zend-mime-usage
Browse files Browse the repository at this point in the history
Eliminate usage of Zend_Mime from Magento 2 Open Source
  • Loading branch information
bbatsche authored Apr 4, 2018
2 parents 7097ea1 + 3645782 commit 4d06c0d
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/code/Magento/Downloadable/Controller/Download.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ protected function _processDownload($path, $resourceType)
$contentDisposition = $helper->getContentDisposition();
if (!$contentDisposition || in_array($contentType, $this->disallowedContentTypes)) {
// For security reasons we force browsers to download the file instead of opening it.
$contentDisposition = \Zend_Mime::DISPOSITION_ATTACHMENT;
$contentDisposition = \Magento\Framework\HTTP\Mime::DISPOSITION_ATTACHMENT;
}

$response->setHeader('Content-Disposition', $contentDisposition . '; filename=' . $fileName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -492,8 +492,8 @@ public function linkNotAvailableDataProvider()
public function downloadTypesDataProvider()
{
return [
['mimeType' => 'text/html', 'disposition' => \Zend_Mime::DISPOSITION_ATTACHMENT],
['mimeType' => 'image/jpeg', 'disposition' => \Zend_Mime::DISPOSITION_INLINE],
['mimeType' => 'text/html', 'disposition' => \Magento\Framework\HTTP\Mime::DISPOSITION_ATTACHMENT],
['mimeType' => 'image/jpeg', 'disposition' => \Magento\Framework\HTTP\Mime::DISPOSITION_INLINE],
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,7 @@ public function testSendAction()
\Magento\TestFramework\Mail\Template\TransportBuilderMock::class
);

$actualResult = \Zend_Mime_Decode::decodeQuotedPrintable(
$transportBuilder->getSentMessage()->getRawMessage()
);
$actualResult = quoted_printable_decode($transportBuilder->getSentMessage()->getRawMessage());

$this->assertStringMatchesFormat(
'%A' . $this->_customerViewHelper->getCustomerName($this->_customerSession->getCustomerDataObject())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4234,5 +4234,6 @@
'Magento\Elasticsearch\Test\Unit\Model\SearchAdapter\ConnectionManagerTest',
'Magento\Elasticsearch\Test\Unit\SearchAdapter\ConnectionManagerTest'
],
['Zend_Feed', 'Zend\Feed']
['Zend_Feed', 'Zend\Feed'],
['Zend_Mime', 'Magento\Framework\HTTP\Mime'],
];
28 changes: 28 additions & 0 deletions lib/internal/Magento/Framework/HTTP/Mime.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php declare(strict_types=1);
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Framework\HTTP;

/**
* Support class for MultiPart Mime Messages
*/
class Mime
{
const TYPE_OCTETSTREAM = 'application/octet-stream';
const TYPE_TEXT = 'text/plain';
const TYPE_HTML = 'text/html';
const ENCODING_7BIT = '7bit';
const ENCODING_8BIT = '8bit';
const ENCODING_QUOTEDPRINTABLE = 'quoted-printable';
const ENCODING_BASE64 = 'base64';
const DISPOSITION_ATTACHMENT = 'attachment';
const DISPOSITION_INLINE = 'inline';
const LINELENGTH = 72;
const LINEEND = "\n";
const MULTIPART_ALTERNATIVE = 'multipart/alternative';
const MULTIPART_MIXED = 'multipart/mixed';
const MULTIPART_RELATED = 'multipart/related';
}

0 comments on commit 4d06c0d

Please sign in to comment.