有用的javascript防注入漏洞过滤函数
3057 点击·0 回帖
![]() | ![]() | |
![]() | <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 | |
![]() | ![]() |