阻止 CheckBoxList 数据源呈现 HTML
我在 VB.NET Web 项目中使用 CheckBoxList。这些元素是从系统中其他地方填充的数据源中提取的。
问题是,如果有人输入一些原始 HTML,CheckBoxList 似乎会呈现它而不是呈现纯文本。
例如,在此屏幕截图中,我输入了将鼠标悬停在此处
,因此现在只要您将鼠标悬停在该复选框上,就会弹出一个警报窗口。这似乎存在潜在的 XSS,我想完全禁用它。
我已经尝试过谷歌搜索并搜索某种方式来禁用 HTML 渲染,例如这样,但没有找到任何相关的内容,所以如果这已经在其他地方得到了回答,我深表歉意。
谢谢!
I am using a CheckBoxList in a VB.NET web project. The elements are pulled from a DataSource which is populated elsewhere in the system.
The problem is, if someone put in some raw HTML, the CheckBoxList seems to render it rather than assume plain text.
In this screenshot, for example, I entered <a href="http://www.google.com" onmouseover="alert('123');">hover here</a>
so now whenever you hover over that CheckBox, an alert window pops up. This seems like a potential for XSS and I would like to disable it altogether.
I have tried googling and searching SO for someway to disable HTML rendering such as this, but haven't found anything relevant, so my apologies if this already has been answered elsewhere.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
绑定数据源后,您应该能够迭代 CheckboxList 中的每个项目并使用 System.Web.HttpServerUtility.HtmlEncode 更新每个项目的 Text 属性。
After binding the datasource, you should be able to iterate through each of the Items in the CheckboxList and use System.Web.HttpServerUtility.HtmlEncode to update each item's Text property.