简体   繁体   English

pebble autoescape json - unicode实体

[英]pebble autoescape json - unicode entities

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.但是,当我已经在创建一个包含此 json 字符串的 utf8 文本文件时,我不希望将字符串编码为 un​​icode 实体 - 它只是不需要且不需要的。

The result should just be this:结果应该是这样的:

{
    "key" : "hellü"
}

Any idea how to disable unicode entities in escape json function?知道如何在转义 json 函数中禁用 unicode 实体吗?

When you see the \\u\u003c/code> representation - that is escaping (not entities).当您看到\\u\u003c/code>表示时 - 这是转义(不是实体)。 So by using autoescape you escaped the json and that is good practice to avoid XSS variabilities .因此,通过使用autoescape转义,您可以转义 json,这是避免 XSS 可变性的好习惯。

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/完整文档: https ://pebbletemplates.io/wiki/guide/escaping/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM