来自数据库的我的数据可能包含一些html。如果我使用
string dataFromDb = "Some text<br />some more <br><ul><li>item 1</li></ul>";
HttpContext.Current.Server.HtmlEncode(dateFromDb);
然后一切都被编码,我在屏幕上看到了安全的Html。
但是,我希望能够执行上面dataFromDb中提到的安全html。
我想我正在尝试创建白名单以进行检查。
答案 0 :(得分:0)
您应该使用Microsoft AntiXSS库。我相信最新版本可用here。具体来说,您需要使用GetSafeHtmlFragment方法。
答案 1 :(得分:0)
结帐this article AntiXSS library也值得一看