-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
Thanks for a very interesting and useful library!
Currently, no escaping children or attributes of inputs is done. This makes the library unsafe for general purpose use IMO.
>>> print(div('<script>alert("danger!")</script>'))
<div><script>alert("danger!")</script></div>>>> print(div(id='">hello'))
<div id="">hello"></div>I think all input strings should be escaped by default (python has html.escape: https://docs.python.org/3/library/html.html
Django has a concept of safe strings where all inputs to templates are escaped by default. When you want to inject trusted HTML, you mark the string as safe with mark_safe:
https://docs.djangoproject.com/en/4.2/_modules/django/utils/safestring/
The convention is basically that an object with a __html__() will not be escaped.
Would you be open to add escaping or accept a PR that implements it?
jh0ker
Metadata
Metadata
Assignees
Labels
No labels