{"id":23189,"library":"xss-utils","title":"xss-utils","description":"xss-utils provides utility functions to sanitize and escape content in Django and Mako templates, helping prevent cross-site scripting (XSS) attacks. Current version 1.0.0 supports Python 3.12, Django up to 5.2, and has dropped Python 3.11. The library is maintained by the Open edX project with regular updates.","status":"active","version":"1.0.0","language":"python","source_language":"en","source_url":"https://github.com/openedx/xss-utils","tags":["xss","security","django","mako","sanitization","openedx"],"install":[{"cmd":"pip install xss-utils","lang":"bash","label":"PyPI install"}],"dependencies":[],"imports":[{"wrong":"from xss_utils.utils import strip_all_tags_unsafe","symbol":"strip_all_tags_unsafe","correct":"from xss_utils import strip_all_tags_unsafe"}],"quickstart":{"code":"from xss_utils.utils import sanitize_html\n\n# Example unsanitized HTML\nunsafe_html = '<script>alert(\"xss\")</script><p>Safe text</p>'\nsafe_html = sanitize_html(unsafe_html)\nprint(safe_html)  # Output: &lt;script&gt;alert(\"xss\")&lt;/script&gt;&lt;p&gt;Safe text&lt;/p&gt;","lang":"python","description":"Sanitize HTML by escaping all HTML tags, preventing XSS injection."},"warnings":[{"fix":"Upgrade to Python 3.12 or later.","message":"Version 1.0.0 dropped Python 3.11 support. Use Python 3.12+.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Use sanitize_html for full escaping of HTML content.","message":"The function strip_all_tags_unsafe does NOT sanitize HTML attributes or scripts; it only strips tags. For safe escaping, use sanitize_html instead.","severity":"gotcha","affected_versions":"all"},{"fix":"Update imports: from xss_utils.utils import sanitize_html","message":"Importing from xss_utils directly is deprecated in favor of importing from xss_utils.utils or xss_utils.filters.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.0.0':30 '3.11':42 '3.12':33 '5.2':37 'attack':27 'content':14 'cross':23 'cross-sit':22 'current':28 'django':16,34,57 'drop':40 'edx':50 'escap':13 'function':9 'help':20 'librari':44 'maintain':46 'mako':18,58 'open':49 'openedx':60 'prevent':21 'project':51 'provid':7 'python':32,41 'regular':53 'sanit':11,59 'script':25 'secur':56 'site':24 'support':31 'templat':19 'updat':54 'util':3,6,8 'version':29 'xss':2,5,26,55 'xss-util':1,4","created_at":"2026-05-01T06:02:53.444461+00:00","updated_at":"2026-05-01T06:02:53.444461+00:00","problems":{"verify_error":"Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\nImportError: cannot import name 'strip_all_tags_unsafe' from 'xss_utils' (/tmp/tmp2mretkr4/venv/lib/python3.12/site-packages/xss_utils/__init__.py)"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.0.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/openedx/xss-utils","docs":null,"changelog":null,"pypi":"https://pypi.org/project/xss-utils/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["auth-security","web-framework"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"import_fail","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-07-10","install_tag":null}}