assembl.lib.clean_input module

assembl.lib.clean_input.sanitize_html(html_value, valid_tags=['a', 'b', 'blockquote', 'code', 'del', 'dd', 'dl', 'dt', 'em', 'i', 'li', 'ol', 'p', 'pre', 's', 'sup', 'sub', 'strike', 'strong', 'table', 'td', 'th', 'tr', 'ul', 'br', 'hr'], valid_attributes=['href', 'alt', 'colspan', 'headers', 'abbr', 'scope', 'sorted'], keep_tag_content=True)[source]

Clean a HTML string, keeping only a subset of tags and attributes.

Parameters
  • valid_tags ([string]) – The name of tags that will be kept.

  • valid_attributes ([string]) – The name of attributes that will be kept. Only used if keep_tag_content is true.

  • keep_tag_content (bool) – Keep the content of tags that are removed

assembl.lib.clean_input.sanitize_text(text)[source]

Clean a HTML string, keeping only the text.