pebble autoescape json - unicode entities

277 Views Asked by At

when I use

{% autoescape "json" %}
{
    "key" : "hellü"
}
{% endautoescape %}

the result is

{
    "key" : "hell\u00FC"
}

But I dont want the strings encoded to unicode entities when I'm already creating a utf8 text file with this json string in it - it is just unneeded and unwanted.

The result should just be this:

{
    "key" : "hellü"
}

Any idea how to disable unicode entities in escape json function?

1

There are 1 best solutions below

1
On

When you see the \u representation - that is escaping (not entities). So by using autoescape you escaped the json and that is good practice to avoid XSS variabilities.

If you still want to disable the autoEscaping you can do:

PebbleEngine engine = new PebbleEngine.Builder().autoEscaping(false).build(); 

For the full documentation: https://pebbletemplates.io/wiki/guide/escaping/