def sanitize_html(html):
	if not isinstance(html, basestring):
		return html

	elif is_json(html):
		return html

	whitelisted_tags = (HTMLSanitizer.acceptable_elements + HTMLSanitizer.svg_elements
		+ ["html", "head", "meta", "link", "body", "iframe", "style", "o:p"])

	# retuns html with escaped tags, escaped orphan >, <, etc.
	escaped_html = bleach.clean(html,
		tags=whitelisted_tags,
		attributes={"*": HTMLSanitizer.acceptable_attributes, "svg": HTMLSanitizer.svg_attributes},
		styles=bleach_whitelist.all_styles,
		strip_comments=False)

	return escaped_html
Sanitize HTML tags, attributes and style to prevent XSS attacks
dataset/ETHPy150Open frappe/frappe/frappe/utils/__init__.py/sanitize_html