How does the javascript-rich text editor prevent xss injection?

Source: Internet
Author: User
If html tags are filtered to prevent xss injection, the rich text editor is useless. If html tags are kept, xss injection is not prevented. Normally, how does one solve this problem ??? Only filter specific tags ??? If html tags are filtered to prevent xss injection, the rich text editor is useless. If html tags are kept, xss injection is not prevented.
Normally, how does one solve this problem ??? Only filter specific tags ???

Reply content:

If html tags are filtered to prevent xss injection, the rich text editor is useless. If html tags are kept, xss injection is not prevented.
Normally, how does one solve this problem ??? Only filter specific tags ???

HTML Purifier is an HTML filter written in PHP. it can be used with the WYSIWYG editor to filter out XSS malicious code.


  purify($html);

I think the white list is good. keep the tags you want to use and filter all others.

If your rich text editor supports any function, no filtering is required. Do you need to know if you have received a p tag and whether it was added manually or in your editor?

Do you want to use your own new syntax?

Just filter out the js script.

Escape as entity character when warehouse receiving
Restore when warehouse is released.
And filter out
Script
Javascript: xxx;
This

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.