Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Eliminate usage of Zend_Mime from Magento 2 Open Source #110

Merged
merged 4 commits into from
Apr 4, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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';
}