pybitmessage.bitmessageqt.safehtmlparser module

Subclass of HTMLParser.HTMLParser for MessageView widget

class SafeHTMLParser(*args, **kwargs)[source]

Bases: HTMLParser.HTMLParser

HTML parser with sanitisation

acceptable_elements = ('a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio', 'b', 'big', 'blockquote', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'command', 'datagrid', 'datalist', 'dd', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'em', 'event-source', 'fieldset', 'figcaption', 'figure', 'footer', 'font', 'header', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'i', 'img', 'ins', 'keygen', 'kbd', 'label', 'legend', 'li', 'm', 'map', 'menu', 'meter', 'multicol', 'nav', 'nextid', 'ol', 'output', 'optgroup', 'option', 'p', 'pre', 'progress', 'q', 's', 'samp', 'section', 'select', 'small', 'sound', 'source', 'spacer', 'span', 'strike', 'strong', 'sub', 'sup', 'table', 'tbody', 'td', 'textarea', 'time', 'tfoot', 'th', 'thead', 'tr', 'tt', 'u', 'ul', 'var', 'video')
replaces_pre = (('&', '&amp;'), ('"', '&quot;'), ('<', '&lt;'), ('>', '&gt;'))
replaces_post = (('\n', '<br/>'), ('\t', '&nbsp;&nbsp;&nbsp;&nbsp;'), (' ', '&nbsp; '), (' ', '&nbsp; '), ('<br/> ', '<br/>&nbsp;'))
src_schemes = ['data']
uriregex1 = <_sre.SRE_Pattern object>
uriregex2 = <_sre.SRE_Pattern object>
emailregex = <_sre.SRE_Pattern object>
static replace_pre(text)

Perform substring replacement before regex replacements

static replace_post(text)

Perform substring replacement after regex replacements

reset_safe()

Reset runtime variables specific to this class

add_if_acceptable(tag, attrs=None)

Add tag if it passes sanitisation

handle_starttag(tag, attrs)
handle_endtag(tag)
handle_startendtag(tag, attrs)
handle_data(data)
handle_charref(name)
handle_entityref(name)
feed(data)
is_html(text=None, allow_picture=False)

Detect if string contains HTML tags