I expect to not escape strings multiple times, even when passed through multiple steps. I this case I pass a variable into a block, which gets rendered and set into a variable, that gets then printed. The result is escaped twice, which means " became ".
Below is the test I wrote in tests/compile.js, I also have it failing, but tbh I have no idea how to make it pass. I invested some time trying to understand the generated code, etc. but I failed. Hints would be very much appreciated. If I can get this to become a PR, I would do it, but I need some guidance.
it('should not escape strings multiple times, even when passed through multiple steps', function() {
const varWithEscapableChars = '"in quotes" and with <brackets>';
const tmpl = new Template('{% set inlineVar %}{% block block1 %}{% endblock %}{% endset %} {{ inlineVar }}');
const multiEscapedString = render('{% extends tmpl %} {% block block1 %}{{ varWithEscapableChars }}{% endblock %}',
{
tmpl: tmpl,
varWithEscapableChars: varWithEscapableChars,
},
{autoescape: true}
);
const singleEscapedString = render('{{ varWithEscapableChars }}',
{
varWithEscapableChars: varWithEscapableChars,
},
{autoescape: true}
);
expect(multiEscapedString).to.equal(singleEscapedString);
});
The test fails like so:
Error: expected ' &quot;in quotes&quot; and with &lt;brackets&gt;' to equal '"in quotes" and with <brackets>'
I expect to not escape strings multiple times, even when passed through multiple steps. I this case I pass a variable into a block, which gets rendered and
set
into a variable, that gets then printed. The result is escaped twice, which means"
became&quot;
.Below is the test I wrote in
tests/compile.js
, I also have it failing, but tbh I have no idea how to make it pass. I invested some time trying to understand the generated code, etc. but I failed. Hints would be very much appreciated. If I can get this to become a PR, I would do it, but I need some guidance.The test fails like so: