{ "info": { "author": "Charlie DeTar", "author_email": "cfd@mdia.mit.edu", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Framework :: Django", "Framework :: Django :: 1.9", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: Dynamic Content" ], "description": "==============================================\nescapejson function and django template filter\n==============================================\n\n**JSON is not javascript.** Many developers erroneously think that they can\njust place the output of ``json.dumps(obj)`` inside ```` within script blocks, and (2) the\nbehavior of two pesky unicode whitespace characters.\n\nThis very simple library provides a function ``escapejson``, and a Django\ntemplate filter of the same name. The output of ``escapejson`` should be safe\nfor inclusion in HTML ``'}\n my_str = json.dumps(myobj)\n my_safe_str = escapejson(my_str)\n\nExample Django templates usage\n------------------------------\n\nFirst, add ``\"escapejson\"`` to ``INSTALLED_APPS`` in your project's ``settings.py``.::\n\n # settings.py\n INSTALLED_APPS = [\n ...,\n \"escapejson\",\n ...,\n ]\n \n\nThen, use the ``escapejson`` library and filter::\n\n {% load escapejson %}\n\n \n\nThis filter will attempt to JSON-encode any non-string object that is passed to it before\nescaping, or just escape any string that is passed to it.\n\n\nWhat it protects against\n========================\n\n attacks\n-----------------\n\nAny string containing a literal ```` inside javascript within HTML\nscript tags will be interpreted by modern browsers as closing the script tag,\nresulting at best in broken scripts and syntax errors, and at worst in\nfull-blown XSS. By escaping all ``/`` characters as ``\\/`` (a valid optional\nescape in the JSON spec), this is mitigated.\n\nU+2028 and U+2029\n-----------------\n\nTwo funky unicode whitespace characters count as valid JSON, but cause syntax\nerrors in javascript. This is mitigated by replacing the literal characters\nwith the strings ``\\u2028`` and ``\\u2029``.\n[`reference `_]", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/yourcelf/escapejson", "keywords": "", "license": "BSD License", "maintainer": "", "maintainer_email": "", "name": "escapejson", "package_url": "https://pypi.org/project/escapejson/", "platform": "", "project_url": "https://pypi.org/project/escapejson/", "project_urls": { "Homepage": "https://github.com/yourcelf/escapejson" }, "release_url": "https://pypi.org/project/escapejson/0.2/", "requires_dist": null, "requires_python": "", "summary": "Escape JSON strings for safe execution as literal javascript and inclusion in HTML