🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

htmlfilter

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

htmlfilter

White list HTML filter

0.2
PyPI
Maintainers
1

About

Very simple white list HTML filter.

Use it with a WYSIWYG editor on the client side.

Usage

:: from htmlfilter import HTMLFilter hf = HTMLFilter() cleaned_html = hf.filter(dirty_html)

Rules file

The filter is instanciated with a predefined set of rules. http://github.com/samueladam/htmlfilter/blob/master/htmlfilter/rules.py

You can create your own rules file::

# file: my_rules.py
TAGS = {
	'a': ('href', 'name',),
	'p': ('class',),
}

# define filters on attributes data (tag_attr)
def p_class(data):
    if data not in ('class1', 'class2',):
        data = ''
    return data

And use them this way::

from htmlfilter import HTMLFilter
import my_rules

hf = HTMLFilter(rules=my_rules)
cleaned_html = hf.filter(dirty_html)

Keywords

html

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts