使用MS防XSS库清理HTML [英] Using MS Anti XSS library for sanitizing HTML

查看:209
本文介绍了使用MS防XSS库清理HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在preventing XSS攻击的意图,我更新的网页中,我们必须能够接受HTML文本框,并将其存储在一个数据库中检索,并在稍后的时间呈现它。

In the intent of preventing XSS attacks, I am updating a page in which we have a textbox that accepts HTML, stores it in a database and retrieves and renders it at a later time.

我的理解是,我可以使用 AntiXSS.GetSafeHtmlFragment()法消毒的HTML。只要我做到这一点存储在数据库中的HTML之前,我有没有佣金?我需要做任何事情时,HTML输出在网页上?

My understanding is that I can sanitize the HTML using AntiXSS.GetSafeHtmlFragment() method. As long as I do this before storing the HTML in the database, am I covered? Do I need to do anything when the HTML is outputted on a web page?

此外,看来白名单是怎样的一个黑匣子。有没有一种方法根据自己的需求来更新这个?

Also, it appears that the white list is kind of a black box. Is there a way to update this based on our requirements?

推荐答案

您应该设置。虽然显然这不会保护你从数据库中的任何事情了。

You should be set. Though obviously this won't protect you from anything already in the database.

您可以使用 AntiXSS.GetSafeHtmlFragment()同时输出保存时的页面,而不是。但保存时做的可能是更安全的。你不希望这样做既渲染的同时,节省虽然。

You could use AntiXSS.GetSafeHtmlFragment() while outputting the page instead of when saving. But doing when saving is probably safer. You would not want to do it both while rendering and saving though.

白名单是不可编辑的。

这篇关于使用MS防XSS库清理HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆