Some people say that you should be careful when storing HTML in MySQL. But what should you pay attention? Some people say that you should be careful when storing HTML in MySQL. But what should you pay attention?
Reply content:
Some people say that you should be careful when storing HTML in MySQL. But what should you pay attention?
SQL injection .........
When MySQL stores HTML code:
1. Use PDO preprocessing to prevent SQL Injection
2.html code should be converted to html entities to prevent XSS attacks
3. If possible, directly filter out the "script" and "script" tags.
0. Security Issues agree that shopex is generally used to deal with these two types of attacks. Use PDO preprocessing to prevent SQL injection and XSS attacks to remove all《script》《script》Labels and labelson*Andjavascript:Url, which can be solved by using HTMLPurifier
1. Because you store html, problems may occur during output. On stackoverflow, someone needs to process the output in tags because the html format is stored.
2. Another problem is that you need to pay attention to the html data format. Considering that html data is usually stored in a large amount, large data volumes are usually supported.blobAndtext, Usually recommendedtext, Big data also hasMEDIUMTEXT
3. It is also because of the problem of html data size. Considering the memory size, if there is a large amount of data, we need to compress the data (here is the advice of MySQL Expert on quora)
The most important thing is to prevent SQL injection and XSS attacks.