&gt; Python&#x27;s Jinja templating language has the concept of &quot;safe&quot; and &quot;unsafe&quot; strings. By default all strings are unsafe (meaning they will be escaped wherever they are rendered) and you need to explicitly mark them as safe in order to be able to treat them as HTML.<p>That&#x27;s good, but it&#x27;s not ideal as it confuses HTML&#x2F;unsafe.  An unwary developer could output untrusted text &quot;safely&quot; and still open up an XSS vulnerability – because they could be outputting to JavaScript embedded within HTML.  Yes, Jinja will encode it as HTML by default, rendering it &quot;safe&quot; in terms of the HTML parser, but that still doesn&#x27;t make it <i>actually</i> safe.<p>Example:<p><pre><code>    alert(&quot;Hello, {{user.name}}!&quot;);
</code></pre>
By default, Jinja will encode this as HTML, meaning that you can&#x27;t trick the HTML parser into injecting your HTML.  But it is still completely vulnerable to the exact same security vulnerability, except by tricking the JavaScript parser.<p>We should recognise what&#x27;s actually the issue at play here.  It&#x27;s not really about whether data is safe or not.  It&#x27;s about correctly encoding data in a manner that&#x27;s suitable for the context in which it is being output.  Sometimes that&#x27;s HTML, sometimes it&#x27;s JavaScript, sometimes it&#x27;s CSS, etc.