Socket
Socket
Sign inDemoInstall

htmlfilter

Package Overview
Dependencies
0
Maintainers
1
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    htmlfilter

White list HTML filter


Maintainers
1

Readme

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

FAQs


Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc