You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@stsewd mentioned a few times that we need to escape all the values we render in the notifications that comes from the user. Due to that, we implement this small trick to run escape() on each of them: #10996
However, we are always passing the instance the notification is attached to (User, Project, Organization, Build, etc) to the Message class to have access to all of fields from it. Due to that, there are some fields like project.name where the user has control and we have to escape() somehow.
I see two possible paths here:
change the rendering engine from regular Python .format()s + trick to call escape() on all the fields and use something like Jinja or regular Django Template Engine where we can call {{ project.name|escape }}
We dealt a few times when rendering notifications using simple Python's
`.format()` and we changed our mind to use Django's engine instead.
Closes#11022
* Notifications: use `Template`'s Django engine to render them
We dealt a few times when rendering notifications using simple Python's
`.format()` and we changed our mind to use Django's engine instead.
Closes#11022
* Revert #11018 and use `instance.name` again
* Update tests
@stsewd mentioned a few times that we need to escape all the values we render in the notifications that comes from the user. Due to that, we implement this small trick to run
escape()
on each of them: #10996However, we are always passing the
instance
the notification is attached to (User, Project, Organization, Build, etc) to theMessage
class to have access to all of fields from it. Due to that, there are some fields likeproject.name
where the user has control and we have toescape()
somehow.I see two possible paths here:
.format()
s + trick to callescape()
on all the fields and use something like Jinja or regular Django Template Engine where we can call{{ project.name|escape }}
.format_map
with a customdict
class that callescape()
on__getitem__
(https://docs.python.org/3/library/stdtypes.html#str.format_map)instance.slug
instead ofinstance.name
#11018The text was updated successfully, but these errors were encountered: