灯火互联
管理员
管理员
  • 注册日期2011-07-27
  • 发帖数41778
  • QQ
  • 火币41290枚
  • 粉丝1086
  • 关注100
  • 终身成就奖
  • 最爱沙发
  • 忠实会员
  • 灌水天才奖
  • 贴图大师奖
  • 原创先锋奖
  • 特殊贡献奖
  • 宣传大使奖
  • 优秀斑竹奖
  • 社区明星
阅读:2506回复:0

有用的javascript防注入漏洞过滤函数

楼主#
更多 发布于:2012-08-24 21:54

<script LANGUAGE="javaScript">
function check(inputStr) {
if (typeof(inputStr) != "string") {
return inputStr;
}
var tmpValue = inputStr; // www.atcpu.com/bbs 以下搜索字符串中的特殊字符,如果存在,则替换成""
while (tmpValue.indexOf(';') > -1) {
tmpValue = tmpValue.replace(';','');
}
while (tmpValue.indexOf('<') > -1) {
tmpValue = tmpValue.replace('<','');
}
while (tmpValue.indexOf('>') > -1) {
tmpValue = tmpValue.replace('>','');
}
while (tmpValue.indexOf('--') > -1) {
tmpValue = tmpValue.replace('--','');
}
while (tmpValue.indexOf(",") > -1) {
tmpValue = tmpValue.replace(",","");
}
while (tmpValue.indexOf("'") > -1) {
tmpValue = tmpValue.replace("'","");
}
while (tmpValue.indexOf("?") > -1) {
tmpValue = tmpValue.replace("?","");
}
document.getElementById("txt1").value = tmpValue;
//重新显示更改后的变量
}
< /script>
本文来源:灯火互联网网[http://www.hx


喜欢0 评分0
游客

返回顶部