当前位置:网站首页>XSS prevention
XSS prevention
2022-07-04 03:20:00 【Ma nongnong tattooed with Guan Ye】
TP6 Packaging usage steps :
① Use composer Carry out orders , install ezyang/htmlpurifier Extended class library
Under project directory
composer require ezyang/htmlpurifier
② stay app/common.php In the definition of remove_xss function
if (!function_exists('remove_xss')) {
// Use htmlpurifier To guard against xss attack
function remove_xss($string){
// relative index.php Entrance file , introduce HTMLPurifier.auto.php Core documents
//require_once './plugins/htmlpurifier/HTMLPurifier.auto.php';
// Generate configuration object
$cfg = HTMLPurifier_Config::createDefault();
// Here is the configuration :
$cfg -> set('Core.Encoding', 'UTF-8');
// Set the allowed HTML label
$cfg -> set('HTML.Allowed','div,b,strong,i,em,a[href|title],ul,ol,li,br,p[style],span[style],img[width|height|alt|src]');
// Set the allowed CSS Style attribute
$cfg -> set('CSS.AllowedProperties', 'font,font-size,font-weight,font-style,font-family,text-decoration,padding-left,color,background-color,text-align');
// Set up a Is it allowed to use... On the label target="_blank"
$cfg -> set('HTML.TargetBlank', TRUE);
// Use configuration to generate objects for filtering
$obj = new HTMLPurifier($cfg);
// Filter strings
return $obj -> purify($string);
}
}
explain :htmlpurifier plug-in unit , It will filter out script The label and what the label contains js Code .
The second kind : Encapsulate global filtering method
Set the global filtering method to htmlspecialchars
[ This method will make the payment function of the initial version unusable ]
| By default, the framework does not set any global filtering rules , You can app\Request Object filter Global filter properties : |
namespace app;
class Request extends \think\Request
{
protected $filter = ['htmlspecialchars'];
}————————————————
Copyright notice : This paper is about CSDN Blogger 「Doc_ACwhite」 The original article of , follow CC 4.0 BY-SA Copyright agreement , For reprint, please attach the original source link and this statement .
Link to the original text :https://blog.csdn.net/Doc_ACwhite/article/details/122924504
边栏推荐
- false sharing
- Rhcsa day 2
- Add IDM to Google browser
- Day05 錶格
- Contest3145 - the 37th game of 2021 freshman individual training match_ 1: Origami
- I stepped on a foundation pit today
- 機器學習基礎:用 Lasso 做特征選擇
- [untitled]
- National standard gb28181 protocol platform easygbs fails to start after replacing MySQL database. How to deal with it?
- (practice C language every day) pointer sorting problem
猜你喜欢
![Backpropagation formula derivation [Li Hongyi deep learning version]](/img/ef/f76eae39c4f8716a0030a60c85b09c.gif)
Backpropagation formula derivation [Li Hongyi deep learning version]

Redis transaction

WP collection plug-in free WordPress collection hang up plug-in

Bugku Zhi, you have to stop him

96% of the collected traffic is prevented by bubble mart of cloud hosting

In my spare time, I like to write some technical blogs and read some useless books. If you want to read more of my original articles, you can follow my personal wechat official account up technology c

Don't disagree, this is the most powerful "language" of the Internet

Network communication basic kit -- IPv4 socket structure

7 * 24-hour business without interruption! Practice of applying multiple live landing in rookie villages

Tsinghua University product: penalty gradient norm improves generalization of deep learning model
随机推荐
system information
The difference between MCU serial communication and parallel communication and the understanding of UART
1day vulnerability pushback skills practice (3)
Node solves cross domain problems
Contest3145 - the 37th game of 2021 freshman individual training match_ E: Eat watermelon
2022 attached lifting scaffold worker (special type of construction work) free test questions and attached lifting scaffold worker (special type of construction work) examination papers 2022 attached
Osnabrueck University | overview of specific architectures in the field of reinforcement learning
Teach you how to optimize SQL
CSP drawing
Unity writes a character controller. The mouse controls the screen to shake and the mouse controls the shooting
Unity knapsack system (code to center and exchange items)
New year's first race, submit bug reward more!
Buuctf QR code
CSCI 2134
Setting methods, usage methods and common usage scenarios of environment variables in postman
Package and download 10 sets of Apple CMS templates / download the source code of Apple CMS video and film website
System integration meets the three business needs of enterprises
Easy to win insert sort
MySQL query
Unity controls the selection of the previous and next characters