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
framework
Filter
Input
MaliciousCode.php
Go to the documentation of this file.
1
<?php
9
namespace
Magento\Framework\Filter\Input
;
10
11
class
MaliciousCode
implements
\Zend_Filter_Interface
12
{
18
protected
$_expressions = [
19
//comments, must be first
20
'/(\/\*.*\*\/)/Us'
,
21
//tabs
22
'/(\t)/'
,
23
//javasript prefix
24
'/(javascript\s*:)/Usi'
,
25
//import styles
26
'/(@import)/Usi'
,
27
//js in the style attribute
28
'/style=[^<]*((expression\s*?\([^<]*?\))|(behavior\s*:))[^<]*(?=\/*>)/Uis'
,
29
//js attributes
30
'/(ondblclick|onclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|'
.
31
'onload|onunload|onerror)=[^<]*(?=\/*>)/Uis'
,
32
//tags
33
'/<\/?(script|meta|link|frame|iframe|object).*>/Uis'
,
34
//base64 usage
35
'/src=[^<]*base64[^<]*(?=\/*>)/Uis'
,
36
];
37
44
public
function
filter
(
$value
)
45
{
46
$replaced = 0;
47
do
{
48
$value
= preg_replace($this->_expressions,
''
,
$value
, -1, $replaced);
49
}
while
($replaced !== 0);
50
return
$value
;
51
}
52
59
public
function
addExpression($expression)
60
{
61
if
(!in_array($expression, $this->_expressions)) {
62
$this->_expressions[] = $expression;
63
}
64
return
$this;
65
}
66
73
public
function
setExpressions(array
$expressions
)
74
{
75
$this->_expressions =
$expressions
;
76
return
$this;
77
}
78
}
$expressions
$expressions
Definition:
side-menu.phtml:10
$value
$value
Definition:
gender.phtml:16
Zend_Filter_Interface
Definition:
Interface.php:30
Magento\Framework\Filter\Input
Definition:
MaliciousCode.php:9
Magento\Framework\Filter\Input\MaliciousCode
Definition:
MaliciousCode.php:11
Zend_Filter_Interface\filter
filter($value)