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
Because, as GitHub helpfully shows, the HTML takes precedence. django-argonauts has a great write-up of the problem. |dump doesn't solve the problem, as it still uses HTML escape codes, rather than JSON.
Is there a way to correctly sanitize this data, without relying on manually chaining |replace calls to strip out the offending characters?
The text was updated successfully, but these errors were encountered:
In Jinja2, it's possible to pass user-controlled data into a template, safe that the browser won't parse it as a script tag:
For example, with
foo = "</script><script>console.log(\'xss\');//"
Becomes:
Which remains a plan string, rather than being parsed as HTML.
However, nunjucks has no such protections. If rendering a template with the same context as above:
Becomes:
Which isn't valid because of the escaping (all fine so far), and marking the string as safe is a security issue:
Because, as GitHub helpfully shows, the HTML takes precedence. django-argonauts has a great write-up of the problem.
|dump
doesn't solve the problem, as it still uses HTML escape codes, rather than JSON.Is there a way to correctly sanitize this data, without relying on manually chaining
|replace
calls to strip out the offending characters?The text was updated successfully, but these errors were encountered: