{ "info": { "author": "NyanKiyoshi", "author_email": "hello@vanille.bid", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "
\n

DraftJS Sanitizer

\n

Sanitizes a DraftJS JSON format from a dict to allow saving. Allows safe dumping into a string in order to prevent injection of quotes and HTML entities.

\n

\n \n Build Status\n \n \n Coverage Status\n \n \n Version\n \n

\n

\n \n Supported versions\n \n \n Supported implementations\n \n

\n
\n\n## Installation\n```\npip install draftjs-sanitizer\n```\n\n## Usage\n\n### Remove known exploits\nThis removes any URLs that could be used for XSS attacks by linking raw javascript code.\n\n```python\nfrom draftjs_sanitizer import clean_draft_js\n\n\nclean_draft_js({\n \"blocks\": [\n {\n \"key\": \"an6ci\",\n \"data\": {},\n \"text\": \"Get Saleor today!\",\n \"type\": \"unstyled\",\n \"depth\": 0,\n \"entityRanges\": [\n {\n \"key\": 0,\n \"length\": 17,\n \"offset\": 0\n }\n ],\n \"inlineStyleRanges\": []\n }\n ],\n \"entityMap\": {\n \"0\": {\n \"data\": {\n \"url\": \"javascript:alert('Oopsie!');\"\n },\n \"type\": \"LINK\",\n \"mutability\": \"MUTABLE\"\n }\n }\n})\n```\n\n### Dump JSON for HTML Usage\nThis allows to run it as a filter in order to prevent any injection or bypass when putting the JSON into HTML code.\n\n```python\nfrom draftjs_sanitizer import to_string\n\ndumped_json = to_string({\"block\": \"\"})\n```\n\n#### Example 1: attribute bypass\n```html\n
alert('Oopsie!');\"}'>
\n```\n\n#### Example 2: bypass inner HTML\n```html\n
\n {\"block\": \"
\"}\n\n```\n\n## Supported Checks\n\n| Type | Entities | Description |\n| ---- | -------- | ----------- |\n| Javascript URL | `IMAGE`, `LINK` | Prevent injecting javascript through the `javascript` protocol into a URL. |\n| Invalid URL | `IMAGE`, `LINK` | Removes any invalid URL from the JSON content. |\n| Dangerous Characters | `any` | Removes any sensible character for HTML incorporation: `\"`, `'`, `<`, `>`.\n\n\n## Development\n```\n./setup.py develop\npip install -r requirements_dev.txt\n```\n\nYou can easily extend the behaviors through:\n- `draftjs_sanitizer.encoder.DraftJSSafeEncoder`\n- `draftjs_sanitizer.sanitizer.DraftJSSanitizer`\n\n## Dependencies\n- `urllib3` for RFC 3986 parsing and validation of URLs.", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/NyanKiyoshi/draftjs-sanitizer/", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "draftjs-sanitizer", "package_url": "https://pypi.org/project/draftjs-sanitizer/", "platform": "", "project_url": "https://pypi.org/project/draftjs-sanitizer/", "project_urls": { "Homepage": "https://github.com/NyanKiyoshi/draftjs-sanitizer/" }, "release_url": "https://pypi.org/project/draftjs-sanitizer/1.0.0/", "requires_dist": null, "requires_python": "", "summary": "Convert basic HTML into DraftJS JSON format.", "version": "1.0.0" }, "last_serial": 5551216, "releases": { "0.0.0.dev2": [ { "comment_text": "", "digests": { "md5": "670565a39b825f8d319fc1f2d55af72a", "sha256": "0a4ce50f855057a6e4d59f51de9389dd1926a9b27f54837582f294d0be616cf9" }, "downloads": -1, "filename": "draftjs-sanitizer-0.0.0.dev2.tar.gz", "has_sig": false, "md5_digest": "670565a39b825f8d319fc1f2d55af72a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6149, "upload_time": "2019-07-18T12:46:38", "url": "https://files.pythonhosted.org/packages/bb/75/601c9d71f3fa92e5538501572f48daccd17a6924449bd3bd31b30b24ba3d/draftjs-sanitizer-0.0.0.dev2.tar.gz" } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "e27053ef0d7645b07f175c22ce317a7b", "sha256": "4603a9296153cd06d5a1d76a45a1ff0295363516af983d8dde28cafc5cd67583" }, "downloads": -1, "filename": "draftjs-sanitizer-1.0.0.tar.gz", "has_sig": false, "md5_digest": "e27053ef0d7645b07f175c22ce317a7b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6149, "upload_time": "2019-07-18T13:21:30", "url": "https://files.pythonhosted.org/packages/58/6c/ba91295b18cf371cab6e7f93f2117eea802ab8e1e491f78ab1361575d07a/draftjs-sanitizer-1.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e27053ef0d7645b07f175c22ce317a7b", "sha256": "4603a9296153cd06d5a1d76a45a1ff0295363516af983d8dde28cafc5cd67583" }, "downloads": -1, "filename": "draftjs-sanitizer-1.0.0.tar.gz", "has_sig": false, "md5_digest": "e27053ef0d7645b07f175c22ce317a7b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6149, "upload_time": "2019-07-18T13:21:30", "url": "https://files.pythonhosted.org/packages/58/6c/ba91295b18cf371cab6e7f93f2117eea802ab8e1e491f78ab1361575d07a/draftjs-sanitizer-1.0.0.tar.gz" } ] }