Baidu Editor Ueditor source mode filter Div/style and other HTML tags

Source: Internet
Author: User
Tags browser cache

Ueditor in the HTML code mode, when the input with <div style= "" >, <iframe> such HTML-tagged content, switch to the editor mode, you will find that the input is deleted, automatically filtered out. Two solutions available:

1, "White list Law", this is the online search for a lot of configuration black and white list, but all applicable to the old version; the new version of the file name has changed a lot, and cannot find the original file described in those methods. However, the principle of a set of procedures is always the same, through a few days of research, try a variety of methods, found that the latest version (1.4.3) also has a so-called "white list", through the configuration can be implemented to the default filter rules to make changes.

In profile ueditor.config.js, about 354 lines, there is a comment://default filter rule related configuration items, here a few lines is the basic switch. Below is an XSS filter, inserthtml and other operations related configuration items, here is the focus of operations, "XSS filtering whitelist" that is ueditor in the source mode, not filtered tags.

For example: We modify Allowdivtranstop to false, add div tag in whitlist{} Whitelist, then clear the browser cache, edit div tag in source mode, add style, switch to editor mode, it will take effect; return to source mode, The div tag still exists.

Similarly, when inserting the video, so that the <embed><iframe> tag is not filtered out, you can add the corresponding tags and attributes in the whitlist{}, respectively:

2, "simple Rough Method": in the file ueditor.all.js, there is a function ue.plugins[' defaultfilter '] = function () {...}, which is commented, the editor default filter conversion mechanism. You can add a return statement directly at the beginning of the function so that all filtering mechanisms do not take effect.

Similarly, do the same with Ueditor.all.min.js: (searchable defaultfilter positioning)

This way, all the filtering mechanisms that Ueditor bring are not valid, and you can use HTML tags freely in source mode.

Baidu Editor Ueditor source mode filter Div/style and other HTML tags

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: 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.