我已经安装了AntiXssLibrary nuget包,它也安装了HtmlSanitizationLibrary。我可以将AntiXssLibrary包含在
`using System.Web.Security.AntiXss;`然后在我的代码中使用它:
`AntiXssEncoder.HtmlEncode(value, true);`我也尝试过用HtmlSanitizationLibrary做同样的事情,但Visual Studio2019无法识别类似的using语句。如何实现/使用HtmlSanitizationLibrary?
发布于 2020-07-01 02:23:18
HtmlSanitizationLibrary被隐藏在一个完全不同的名称空间中,即使它与相同的库一起安装。
using Microsoft.Security.Application;
string html_fragment = "some unsafe html containing XSS";
string safe_html = Sanitizer.GetSafeHtmlFragment(html_fragment);参见https://documentation.help/Microsoft-AntiXSS/documentation.pdf,第162 - 165页。
https://stackoverflow.com/questions/57383745
复制相似问题