Skip to content

Commit e987ab9

Browse files
AC-11831 improve product custom option validation
1 parent 017ec8b commit e987ab9

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

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

+16-4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
*/
2121
class ValidatorInfo extends Validator
2222
{
23+
/**
24+
* @var string
25+
*/
26+
private const PATH_PREFIX = 'custom_options';
27+
2328
/**
2429
* @var Database
2530
*/
@@ -49,6 +54,7 @@ class ValidatorInfo extends Validator
4954
* @var IoFile
5055
*/
5156
private $ioFile;
57+
5258
/**
5359
* @var NotProtectedExtension
5460
*/
@@ -146,13 +152,19 @@ public function validate($optionValue, $option)
146152
private function validatePath(array $optionValuePath): bool
147153
{
148154
foreach ([$optionValuePath['quote_path'], $optionValuePath['order_path']] as $path) {
155+
if (strpos($path, self::PATH_PREFIX) !== 0) {
156+
return false;
157+
}
158+
149159
$pathInfo = $this->ioFile->getPathInfo($path);
150-
if (isset($pathInfo['extension'])) {
151-
if (!$this->fileValidator->isValid($pathInfo['extension'])) {
152-
return false;
153-
}
160+
161+
if (isset($pathInfo['extension'])
162+
&& ($pathInfo['extension'] === '' || !$this->fileValidator->isValid($pathInfo['extension']))
163+
) {
164+
return false;
154165
}
155166
}
167+
156168
return true;
157169
}
158170

pub/media/.htaccess

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Options -Indexes
1111
AddHandler cgi-script .php .pl .py .jsp .asp .htm .shtml .sh .cgi
1212
Options -ExecCGI
1313

14-
<FilesMatch ".+\.(ph(p[3457]?|t|tml)|[aj]sp|p[ly]|sh|cgi|shtml?|html?)$">
14+
<FilesMatch ".*\.(ph(p[3457]?|t|tml)|[aj]sp|p[ly]|sh|cgi|shtml?|html?)$">
1515
SetHandler default-handler
1616
</FilesMatch>
1717

0 commit comments

Comments
 (0)