Skip to main content

Ammonia HTML sanitizer Python binding

Project description

nh3

CI PyPI Documentation Status

ammonia Python binding.

Installation

pip install nh3

Usage

import nh3

print(nh3.clean("<b><img src=\"\">I'm not trying to XSS you</b>"))

Performance

Running on MacBook Air (M2, 2022)

Python 3.11.0 (main, Oct 25 2022, 16:25:24) [Clang 14.0.0 (clang-1400.0.29.102)]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.9.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import requests

In [2]: import bleach

In [3]: import nh3

In [4]: html = requests.get("https://www.google.com").text

In [5]: %timeit bleach.clean(html)
2.85 ms ± 22.8 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)

In [6]: %timeit nh3.clean(html)
138 µs ± 860 ns per loop (mean ± std. dev. of 7 runs, 10,000 loops each)

License

This work is released under the MIT license. A copy of the license is provided in the LICENSE file.

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

nh3-0.2.10.tar.gz (14.1 kB view hashes)

Uploaded Source

Built Distributions

nh3-0.2.10-cp37-abi3-win_amd64.whl (565.3 kB view hashes)

Uploaded CPython 3.7+ Windows x86-64

nh3-0.2.10-cp37-abi3-win32.whl (564.7 kB view hashes)

Uploaded CPython 3.7+ Windows x86

nh3-0.2.10-cp37-abi3-musllinux_1_2_x86_64.whl (1.8 MB view hashes)

Uploaded CPython 3.7+ musllinux: musl 1.2+ x86-64

nh3-0.2.10-cp37-abi3-musllinux_1_2_i686.whl (1.8 MB view hashes)

Uploaded CPython 3.7+ musllinux: musl 1.2+ i686

nh3-0.2.10-cp37-abi3-musllinux_1_2_armv7l.whl (1.9 MB view hashes)

Uploaded CPython 3.7+ musllinux: musl 1.2+ ARMv7l

nh3-0.2.10-cp37-abi3-musllinux_1_2_aarch64.whl (1.8 MB view hashes)

Uploaded CPython 3.7+ musllinux: musl 1.2+ ARM64

nh3-0.2.10-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.6 MB view hashes)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ x86-64

nh3-0.2.10-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (1.9 MB view hashes)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ s390x

nh3-0.2.10-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (1.8 MB view hashes)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ ppc64le

nh3-0.2.10-cp37-abi3-manylinux_2_17_ppc64.manylinux2014_ppc64.whl (1.8 MB view hashes)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ ppc64

nh3-0.2.10-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (1.6 MB view hashes)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ ARMv7l

nh3-0.2.10-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.7 MB view hashes)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ ARM64

nh3-0.2.10-cp37-abi3-manylinux_2_5_i686.manylinux1_i686.whl (1.7 MB view hashes)

Uploaded CPython 3.7+ manylinux: glibc 2.5+ i686

nh3-0.2.10-cp37-abi3-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (1.4 MB view hashes)

Uploaded CPython 3.7+ macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

nh3-0.2.10-cp37-abi3-macosx_10_7_x86_64.whl (726.4 kB view hashes)

Uploaded CPython 3.7+ macOS 10.7+ x86-64

Supported by

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