New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
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
  • Socket score

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

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc