bleached


Namebleached JSON
Version 1.0.0 PyPI version JSON
download
home_page
SummaryValidate HTML against a small subset (for example generated by bleach)
upload_time2023-04-04 23:54:02
maintainer
docs_urlNone
authorRemi Rampin
requires_python>=3.5,<4.0
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # bleached

This is a small HTML checker. It can validate that HTML code is safe.

It does not aim to support the entire HTML spec, rather it focuses on checking HTML that has been run through a sanitizer (such as [bleach](https://github.com/mozilla/bleach)).

## How to use?

```
$ pip install bleached
$ python3
>>> import bleached
>>> bleached.is_html_bleached('<p>Hello world</p>')
True
>>> bleached.is_html_bleached('<script>alert("Hello world");</script>')
False
>>> bleached.check_html('<p>Hello world</p>')
>>> bleached.check_html('<script>alert("Hello world");</script>')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
bleached.UnsafeInput: Line 1 character 8 (input index 7): Found forbidden opening tag 'script'
```

## Why use this?

[bleach](https://github.com/mozilla/bleach) is a great library for sanitizing untrusted HTML. You should use it instead of this where possible.

However, it offers no way to check that a piece of HTML has been sanitized. Running the HTML through bleach again will only work if you have the exact same version, as bleach makes no guarantee of stability of their input. This is where bleached is useful.

## Warnings

* No validation of attributes is performed. If you choose to allow an attribute, it is up to you to validate the values.
* This accepts a much smaller subset of HTML than web browsers. Be ready for false negatives if you use this to validate HTML documents.


            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "bleached",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.5,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "Remi Rampin",
    "author_email": "remi@rampin.org",
    "download_url": "https://files.pythonhosted.org/packages/06/60/c854a64b36bec0f3262b2f346c469dc51ace1fbaddee1936a669036e5682/bleached-1.0.0.tar.gz",
    "platform": null,
    "description": "# bleached\n\nThis is a small HTML checker. It can validate that HTML code is safe.\n\nIt does not aim to support the entire HTML spec, rather it focuses on checking HTML that has been run through a sanitizer (such as [bleach](https://github.com/mozilla/bleach)).\n\n## How to use?\n\n```\n$ pip install bleached\n$ python3\n>>> import bleached\n>>> bleached.is_html_bleached('<p>Hello world</p>')\nTrue\n>>> bleached.is_html_bleached('<script>alert(\"Hello world\");</script>')\nFalse\n>>> bleached.check_html('<p>Hello world</p>')\n>>> bleached.check_html('<script>alert(\"Hello world\");</script>')\nTraceback (most recent call last):\n  File \"<stdin>\", line 1, in <module>\nbleached.UnsafeInput: Line 1 character 8 (input index 7): Found forbidden opening tag 'script'\n```\n\n## Why use this?\n\n[bleach](https://github.com/mozilla/bleach) is a great library for sanitizing untrusted HTML. You should use it instead of this where possible.\n\nHowever, it offers no way to check that a piece of HTML has been sanitized. Running the HTML through bleach again will only work if you have the exact same version, as bleach makes no guarantee of stability of their input. This is where bleached is useful.\n\n## Warnings\n\n* No validation of attributes is performed. If you choose to allow an attribute, it is up to you to validate the values.\n* This accepts a much smaller subset of HTML than web browsers. Be ready for false negatives if you use this to validate HTML documents.\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Validate HTML against a small subset (for example generated by bleach)",
    "version": "1.0.0",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "11cfa0725af201c75d9828e35c0bb4d4d7b60f857964ea142aaeaf5485647ad3",
                "md5": "e596911de2d14cfa6e4dee1e893fe209",
                "sha256": "84c0e737e59ded62f852cccb09b35303a9a6bb29214acb4d893f395c5d963301"
            },
            "downloads": -1,
            "filename": "bleached-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e596911de2d14cfa6e4dee1e893fe209",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.5,<4.0",
            "size": 4172,
            "upload_time": "2023-04-04T23:54:22",
            "upload_time_iso_8601": "2023-04-04T23:54:22.165866Z",
            "url": "https://files.pythonhosted.org/packages/11/cf/a0725af201c75d9828e35c0bb4d4d7b60f857964ea142aaeaf5485647ad3/bleached-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0660c854a64b36bec0f3262b2f346c469dc51ace1fbaddee1936a669036e5682",
                "md5": "a900dbe92f7ef82573fcb253ef1461b1",
                "sha256": "2db92a18bdfb8df4b3d0e47ffb3e8a48dd5dc35b0a1b99e88f331da36fd0c6c0"
            },
            "downloads": -1,
            "filename": "bleached-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "a900dbe92f7ef82573fcb253ef1461b1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.5,<4.0",
            "size": 4124,
            "upload_time": "2023-04-04T23:54:02",
            "upload_time_iso_8601": "2023-04-04T23:54:02.845740Z",
            "url": "https://files.pythonhosted.org/packages/06/60/c854a64b36bec0f3262b2f346c469dc51ace1fbaddee1936a669036e5682/bleached-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-04 23:54:02",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "bleached"
}
        
Elapsed time: 0.33553s