0

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?

DubZ
  • 580
  • 3
  • 12

1 Answers1

0

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/

Zvi Azran
  • 91
  • 6
  • Hi, sorry but I'm not fully agreeing. I see a difference between JSON control character escape and unicode escape/entities (escape/entities... for me the same). I think it has to be looked seperately. umlauts and other unicode characters, which are no control character in json (unicode character like üäöáâè) can be clearly written in a utf8 json as plain unicode character. control characters like " ' { [ etc. has to be escaped by RFC standard, JSON text not by force: https://datatracker.ietf.org/doc/html/rfc7159#section-7 section 7 and 8 – DubZ Jan 14 '22 at 09:15