I'm experiencing a strange problem I haven't run into before. My html is generated via Django templates, and consist of some basic code that initializes a DataTable based on a query string with some GET variables (i.e. "/report1/?filter1=abc&filter2=def").
However, all of a sudden, whenever I write the Django template variable out within a <script></script> tag the & is converted to &, like this:
<script>
var link = "/report1/?filter1=abc&filter2=def"
</script>
However, when not inside a script tag, the string outputs as originally intended:
"/report1/?filter1=abc&filter2=def"
This is based off the exact same Django template variable with no changes.
What about the script is causing the & to be encoded? This happens in current versions of Edge and Firefox. Django clearly doesn't know anything about the <script></script> tags so it must be a browser thing.
Any ideas how to prevent this from happening? It is something that didn't seem to happen in the past.
Thanks!
For reference, my Django template looks something like this:
{{ string }}<br>
<script>
var link = "{{ string }}"
</script>
Okay, so my mess up, when I updated to the latest versions, I neglected to realized that strings needed to be marked with |safe now
Of course I realized this only after writing out this post.