检查脚本asp.net文本框中 [英] Check for script in asp.net text box

查看:97
本文介绍了检查脚本asp.net文本框中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们想阻止用户输入查询HTML或JavaScript在文本框中。

We would like to stop users inputing html or javascript in a text box.

我们可以只分析输入和检查尖括号。不知道有没有更好的方式来做到这一点?

We can just parse the input and check for angel brackets. Was wondering is there a better way to do this?

推荐答案

我发现,与替换尖括号EN codeD尖括号解决了大部分问题。这里是人们可以跨站点的所有方式脚本参考。制作一个正则表达式来阻止任何HTML风味和或Script是该死的几乎是不可能的。

I have found that replacing the angel brackets with encoded angel brackets solves most problems. Here is a reference for all the ways people can cross-site script. Making a regex to stop any flavor of HTML and or Script is damn near impossible.

这篇关于检查脚本asp.net文本框中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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