I want to write a web application that allows users to enter any HTML that may occur inside a <div> element. Then this HTML code will be displayed to other users, so I want to make sure that the site does not open to people before XSS attacks.
Is there a good library in Python that will clear all event handler attributes, <script> elements and other Javascript related to HTML or DOM tree?
I intend to use Beautiful Soup to organize my HTML to make sure that it doesn't contain any private tags or the like. But, as far as I can tell, it has no pre-packaged way to remove all Javascript.
If there is a good library in another language, this might also work, but I would prefer Python.
I did a bunch of google searches and hunted for pypi but couldn't find anything obvious.
Related
source share