Skip to content

Commit 60b24eb

Browse files
Merge pull request #2742 from magento-qwerty/2.1.15-bugfixes-210618
Fixed issues: - MAGETWO-72023: Wysiwyg editor incorrectly processes attributes of HTML5 tags - MAGETWO-92164: [Backport for 2.1.x] Redundancy in Custom Option Filenames - MAGETWO-88668: [Backport for 2.1.x] Invalid Print Order Layout - MAGETWO-88656: [Backport for 2.1.x] Sales Rule Widget Label - MAGETWO-92199: Some Underscore templates are broken
2 parents 7ad54c8 + e468572 commit 60b24eb

File tree

12 files changed

+68
-617
lines changed

12 files changed

+68
-617
lines changed

app/code/Magento/Backend/view/adminhtml/templates/system/search.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<% if (data.items.length) { %>
4343
<% _.each(data.items, function(value){ %>
4444
<li class="item"
45-
<%- data.optionData(value) %>
45+
<%= data.optionData(value) %>
4646
>
4747
<a href="<%- value.url %>" class="title"><%- value.name %></a>
4848
<span class="type"><%- value.type %></span>

app/code/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFile.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
use Magento\Framework\App\Filesystem\DirectoryList;
1111
use Magento\Catalog\Model\Product\Exception as ProductException;
1212
use Magento\Framework\Exception\LocalizedException;
13+
use Magento\Framework\Math\Random;
14+
use Magento\Framework\App\ObjectManager;
1315

1416
/**
1517
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -62,25 +64,34 @@ class ValidatorFile extends Validator
6264
*/
6365
protected $isImageValidator;
6466

67+
/**
68+
* @var Random
69+
*/
70+
private $random;
71+
6572
/**
6673
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
6774
* @param \Magento\Framework\Filesystem $filesystem
6875
* @param \Magento\Framework\File\Size $fileSize
6976
* @param \Magento\Framework\HTTP\Adapter\FileTransferFactory $httpFactory
7077
* @param \Magento\Framework\Validator\File\IsImage $isImageValidator
78+
* @param Random|null $random
7179
* @throws \Magento\Framework\Exception\FileSystemException
7280
*/
7381
public function __construct(
7482
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
7583
\Magento\Framework\Filesystem $filesystem,
7684
\Magento\Framework\File\Size $fileSize,
7785
\Magento\Framework\HTTP\Adapter\FileTransferFactory $httpFactory,
78-
\Magento\Framework\Validator\File\IsImage $isImageValidator
86+
\Magento\Framework\Validator\File\IsImage $isImageValidator,
87+
Random $random = null
7988
) {
8089
$this->mediaDirectory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA);
8190
$this->filesystem = $filesystem;
8291
$this->httpFactory = $httpFactory;
8392
$this->isImageValidator = $isImageValidator;
93+
$this->random = $random
94+
? $random : ObjectManager::getInstance()->get(Random::class);
8495
parent::__construct($scopeConfig, $filesystem, $fileSize);
8596
}
8697

@@ -147,16 +158,14 @@ public function validate($processingParams, $option)
147158
$userValue = [];
148159

149160
if ($upload->isUploaded($file) && $upload->isValid($file)) {
150-
$extension = pathinfo(strtolower($fileInfo['name']), PATHINFO_EXTENSION);
151-
152161
$fileName = \Magento\MediaStorage\Model\File\Uploader::getCorrectFileName($fileInfo['name']);
153162
$dispersion = \Magento\MediaStorage\Model\File\Uploader::getDispretionPath($fileName);
154163

155164
$filePath = $dispersion;
156165

157166
$tmpDirectory = $this->filesystem->getDirectoryRead(DirectoryList::SYS_TMP);
158-
$fileHash = md5($tmpDirectory->readFile($tmpDirectory->getRelativePath($fileInfo['tmp_name'])));
159-
$filePath .= '/' . $fileHash . '.' . $extension;
167+
$fileHash = $this->random->getRandomString(32);
168+
$filePath .= '/' . $fileHash;
160169
$fileFullPath = $this->mediaDirectory->getAbsolutePath($this->quotePath . $filePath);
161170

162171
$upload->addFilter(new \Zend_Filter_File_Rename(['target' => $fileFullPath, 'overwrite' => true]));

app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit/attribute_set.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<% } %>
1515
<ul data-mage-init='{"menu":[]}'>
1616
<% _.each(data.items, function(value) { %>
17-
<li <%- data.optionData(value) %>><a href="#"><%- value.label %></a></li>
17+
<li <%= data.optionData(value) %>><a href="#"><%- value.label %></a></li>
1818
<% }); %>
1919
</ul>
2020
<% if (!data.term && data.items.length && !data.allShown()) { %>

app/code/Magento/Sales/Model/Download.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ public function downloadFile($info)
7878
$this->_fileFactory->create(
7979
$info['title'],
8080
['value' => $this->_rootDir->getRelativePath($relativePath), 'type' => 'filename'],
81-
$this->rootDirBasePath
81+
$this->rootDirBasePath,
82+
$info['type']
8283
);
8384
}
8485

0 commit comments

Comments
 (0)