Extension point for intercepting HTML before DOM insertion #1747
Description
Originally reported by nicholas@… at: http://bugs.jquery.com/ticket/14228
At my company, there's a desire to filter HTML strings as they go through methods like html() and append() to prevent XSS. Our code base is quite large and there are thousands of references to these types of methods that accept an HTML string for DOM insertion, so it's not feasible to replace each instance with our own method call.
As far as I can tell, there's no current way to intercept HTML strings before insertion. What I'm suggesting is adding some kind of extension point to jQuery Core that would allow someone to register a function that would receive the HTML before insertion and allow someone to change that HTML that would actually be inserted. This has the following potential uses:
- custom XSS filters
- auto linking filters (automatically turn an email address into a link, for example)
- stripping out personal data
Just to be clear, I'm not suggesting including anything other than an extension point that would allow such filters to be written. Without this, I need to basically overwrite html(), append(), prepend(), and all the others to manfully check any string arguments.
Issue reported for jQuery 1.10.2