This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sanitize(untrusted_html, additional_tags=None): | |
"""Strips potentially harmful tags and attributes from HTML, but preserves | |
all tags in a whitelist. | |
Passing the list additional_tags will add the specified tags to the whitelist. | |
The sanitizer does NOT encode reserved characters into XML entities. It is up | |
to the template code, if any, to take care of that. | |
Based on the work of: |
NewerOlder