Skip to main content

Drop-in replacement for bleach HTML sanitization library

Project description

blanch

Drop-in replacement for bleach, the deprecated HTML sanitization library.

Features

  • Same API as bleach (clean, linkify, Cleaner, Linker, CSSSanitizer)
  • Zero dependencies — uses html.parser from stdlib
  • Python 3.10+
  • Full type annotations

Installation

pip install blanch

Usage

import blanch

# Sanitize HTML
blanch.clean("<script>alert('xss')</script><b>hello</b>")
# '&lt;script&gt;alert(\'xss\')&lt;/script&gt;<b>hello</b>'

# Linkify URLs
blanch.linkify("Visit https://example.com")
# 'Visit <a href="https://example.com" rel="nofollow">https://example.com</a>'

Migrating from bleach

# Option 1: Replace import
# Before: import bleach
import blanch as bleach

# Option 2: Use compatibility layer
import blanch.compat.bleach as bleach

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

blanch-0.1.0.tar.gz (39.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

blanch-0.1.0-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file blanch-0.1.0.tar.gz.

File metadata

  • Download URL: blanch-0.1.0.tar.gz
  • Upload date:
  • Size: 39.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for blanch-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9c42f39cc7405bfb809f6b80064e61aa23e32e67cbbbc95f35fcbf4bb8970a8b
MD5 eb42e9caa9ad75b52b0b7af311e253c9
BLAKE2b-256 752ed031041e6a16d8ec599cf82d0c069a19d9c9238debb6029e7c42ca4ca783

See more details on using hashes here.

File details

Details for the file blanch-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: blanch-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for blanch-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f0dbc083d0b3ce79a54714063ccf46cf19176a26d810f64954d3148de5716fb7
MD5 7344eb202f84b4671b73ce95d1605308
BLAKE2b-256 faaca6b51e5296bac5e299a3822c7ac95429e725103d8fecb962b703e2b8efc6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page