Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
module-downloadable
Model
File
ContentValidator.php
Go to the documentation of this file.
1
<?php
6
namespace
Magento\Downloadable\Model\File
;
7
8
use
Magento\Downloadable\Api\Data\File\ContentInterface
;
9
use
Magento\Framework\Exception\InputException
;
10
11
class
ContentValidator
12
{
20
public
function
isValid
(
ContentInterface
$fileContent)
21
{
22
$decodedContent = @base64_decode($fileContent->
getFileData
(),
true
);
23
if
(empty($decodedContent)) {
24
throw
new
InputException
(
__
(
'Provided content must be valid base64 encoded data.'
));
25
}
26
27
if
(!$this->
isFileNameValid
($fileContent->
getName
())) {
28
throw
new
InputException
(
__
(
'Provided file name contains forbidden characters.'
));
29
}
30
return
true
;
31
}
32
39
protected
function
isFileNameValid
(
$fileName
)
40
{
41
// Cannot contain \ / : * ? " < > |
42
if
(!preg_match(
'/^[^\\/?*:";<>()|{}\\\\]+$/'
,
$fileName
)) {
43
return
false
;
44
}
45
return
true
;
46
}
47
}
Magento\Downloadable\Api\Data\File\ContentInterface\getName
getName()
Magento\Downloadable\Model\File\ContentValidator
Definition:
ContentValidator.php:11
__
__()
Definition:
__.php:13
Magento\Downloadable\Api\Data\File\ContentInterface
Definition:
ContentInterface.php:13
Magento\Framework\Exception\InputException
Definition:
InputException.php:17
$fileName
$fileName
Definition:
translate.phtml:15
Magento\Downloadable\Api\Data\File\ContentInterface\getFileData
getFileData()
Magento\Downloadable\Model\File\ContentValidator\isValid
isValid(ContentInterface $fileContent)
Definition:
ContentValidator.php:20
Magento\Downloadable\Model\File\ContentValidator\isFileNameValid
isFileNameValid($fileName)
Definition:
ContentValidator.php:39
Magento\Downloadable\Model\File
Definition:
Content.php:6