屏蔽script注入小例子_javascript技巧
程序员文章站
2022-05-24 08:27:18
...
字符串过滤
static public string HtmlEncode(string str)
{
str = str.Replace("&", "&");
str = str.Replace("str = str.Replace(">", ">");
str = str.Replace("'", "''");
str = str.Replace("*", "");
str = str.Replace("\n", "
");
str = str.Replace("\r\n", "
");
//str = str.Replace("?","");
str = str.Replace("select", "");
str = str.Replace("insert", "");
str = str.Replace("update", "");
str = str.Replace("delete", "");
str = str.Replace("create", "");
str = str.Replace("drop", "");
str = str.Replace("delcare", "");
if (str.Trim().ToString() == "") { str = "无"; }
return str.Trim();
}
复制代码 代码如下:
static public string HtmlEncode(string str)
{
str = str.Replace("&", "&");
str = str.Replace("str = str.Replace(">", ">");
str = str.Replace("'", "''");
str = str.Replace("*", "");
str = str.Replace("\n", "
");
str = str.Replace("\r\n", "
");
//str = str.Replace("?","");
str = str.Replace("select", "");
str = str.Replace("insert", "");
str = str.Replace("update", "");
str = str.Replace("delete", "");
str = str.Replace("create", "");
str = str.Replace("drop", "");
str = str.Replace("delcare", "");
if (str.Trim().ToString() == "") { str = "无"; }
return str.Trim();
}
推荐阅读
-
扩展JS Date对象时间格式化功能的小例子_javascript技巧
-
js 验证密码强弱的小例子_javascript技巧
-
JavaScript设置首页和收藏页面的小例子_javascript技巧
-
javascript中日期转换成时间戳的小例子_javascript技巧
-
js实现点击注册按钮开始读秒倒计时的小例子_javascript技巧
-
javascrip关于继承的小例子_javascript技巧
-
JS获取地址栏参数的小例子_javascript技巧
-
javascript 手动给表增加数据的小例子_javascript技巧
-
js同比例缩放图片的小例子_javascript技巧
-
JS在textarea光标处插入文本的小例子_javascript技巧