在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
参考资料:https://docs.microsoft.com/en-us/aspnet/core/security/cross-site-scripting Customizing the EncodersBy default encoders use a safe list limited to the Basic Latin Unicode range and encode all characters outside of that range as their character code equivalents. This behavior also affects Razor TagHelper and HtmlHelper rendering as it will use the encoders to output your strings. The reasoning behind this is to protect against unknown or future browser bugs (previous browser bugs have tripped up parsing based on the processing of non-English characters). If your web site makes heavy use of non-Latin characters, such as Chinese, Cyrillic or others this is probably not the behavior you want. You can customize the encoder safe lists to include Unicode ranges appropriate to your application during startup, in For example, using the default configuration you might use a Razor HtmlHelper like so; Copy
html
When you view the source of the web page you will see it has been rendered as follows, with the Chinese text encoded; Copy
html
To widen the characters treated as safe by the encoder you would insert the following line into the Copy
C#
This example widens the safe list to include the Unicode Range CjkUnifiedIdeographs. The rendered output would now become Copy
html
code charts you can use to find the chart containing your characters. Each encoder, Html, JavaScript and Url, must be configured separately. NoteCustomization of the safe list only affects encoders sourced via DI. If you directly access an encoder via |
请发表评论