当前位置:网站首页>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
边栏推荐
- @Scheduled scheduled tasks
- 長文綜述:大腦中的熵、自由能、對稱性和動力學
- How about the ratings of 2022 Spring Festival Gala in all provinces? Map analysis helps you show clearly!
- There is no need to authorize the automatic dream weaving collection plug-in for dream weaving collection
- Global and Chinese market of digital impression system 2022-2028: Research Report on technology, participants, trends, market size and share
- [Valentine's Day confession code] - Valentine's Day is approaching, and more than 10 romantic love effects are given to the one you love
- 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
- Code Execution Vulnerability - no alphanumeric rce create_ function()
- Easy to win insert sort
- Unity knapsack system (code to center and exchange items)
猜你喜欢

Is it really so difficult to learn redis? Today, a fan will share his personal learning materials!
![[source code analysis] model parallel distributed training Megatron (5) -- pipestream flush](/img/94/2bdc31ec05595dbbc8a7a8d6b22252.jpg)
[source code analysis] model parallel distributed training Megatron (5) -- pipestream flush

Li Chuang EDA learning notes IX: layers

Redis transaction

Rhcsa day 3

Explain AI accelerator in detail: why is this the golden age of AI accelerator?

Talking about custom conditions and handling errors in MySQL Foundation

I stepped on a foundation pit today

How about the ratings of 2022 Spring Festival Gala in all provinces? Map analysis helps you show clearly!

No clue about the data analysis report? After reading this introduction of smartbi, you will understand!
随机推荐
PHP database connection succeeded, but data cannot be inserted
Eh, the log time of MySQL server is less than 8h?
Baijia forum the founding of the Eastern Han Dynasty
Formulaire day05
WP collection plug-in free WordPress collection hang up plug-in
Cache general management class + cache httpcontext Current. Cache and httpruntime Differences between caches
[database I] database overview, common commands, view the table structure of 'demo data', simple query, condition query, sorting data, data processing function (single row processing function), groupi
Fudan released its first review paper on the construction and application of multimodal knowledge atlas, comprehensively describing the existing mmkg technology system and progress
ZABBIX API batch delete a template of the host
Have you entered the workplace since the first 00???
MySQL workbench use
What are the virtual machine software? What are their respective functions?
Li Chuang EDA learning notes 13: electrical network for drawing schematic diagram
Contest3145 - the 37th game of 2021 freshman individual training match_ J: Eat radish
Package and download 10 sets of Apple CMS templates / download the source code of Apple CMS video and film website
1day vulnerability pushback skills practice (3)
Global and Chinese markets of advanced X-ray inspection system (Axi) in PCB 2022-2028: Research Report on technology, participants, trends, market size and share
(column 23) typical C language problem: find the minimum common multiple and maximum common divisor of two numbers. (two solutions)
Basé sur... Netcore Development blog Project Starblog - (14) Implementation of theme switching function
The difference between MCU serial communication and parallel communication and the understanding of UART