防止恶意字符输入
来源:互联网 发布:怎样装修淘宝店铺 编辑:程序博客网 时间:2024/04/30 10:03
public static string InputText(string text, int maxLength)
...{
if (string.IsNullOrEmpty(text))
return string.Empty;
text = text.Trim();
if (string.IsNullOrEmpty(text))
return string.Empty;
if (text.Length > maxLength)
text = text.Substring(0, maxLength);
text = Regex.Replace(text, "[/s]{2,}", " "); //two or more spaces
text = Regex.Replace(text, "(<[b|B][r|R]/*>)+|(<[p|P](.|/n)*?>)", " "); //<br>
text = Regex.Replace(text, "(/s*&[n|N][b|B][s|S][p|P];/s*)+", " "); //
text = Regex.Replace(text, "<(.|/n)*?>", string.Empty); //any other tags
text = text.Replace("'", "''");
return text;
}
...{
if (string.IsNullOrEmpty(text))
return string.Empty;
text = text.Trim();
if (string.IsNullOrEmpty(text))
return string.Empty;
if (text.Length > maxLength)
text = text.Substring(0, maxLength);
text = Regex.Replace(text, "[/s]{2,}", " "); //two or more spaces
text = Regex.Replace(text, "(<[b|B][r|R]/*>)+|(<[p|P](.|/n)*?>)", " "); //<br>
text = Regex.Replace(text, "(/s*&[n|N][b|B][s|S][p|P];/s*)+", " "); //
text = Regex.Replace(text, "<(.|/n)*?>", string.Empty); //any other tags
text = text.Replace("'", "''");
return text;
}
- 防止恶意字符输入
- .NET防止用户恶意输入
- AcceptEx防止恶意攻击
- php 防止恶意刷新
- 防止恶意登录机制
- 防止恶意点击
- apache防止恶意解析
- 防止SQL注入和特殊字符输入
- EditText防止输入空格、换行、限制输入字符长度
- 防止恶意入侵后台管理
- 防止恶意提交的方法
- 防止用户恶意刷新过滤器
- 主机防止域名恶意解析
- 如何防止恶意POST数据?
- wordpress防止博客恶意采集
- php token防止恶意提交
- 防止恶意ddos抓取攻击
- 防止用户恶意刷新过滤器
- PL/SQL Developer中,存储过程无法调试的问题解决办法
- 联想千万元投资个性定制网站
- Jakarta-Common-BeanUtils使用笔记
- Commons-logging + Log4j 入门指南
- 成为信用卡的主人—信用卡理财系列之二
- 防止恶意字符输入
- EZW算法的过程详解和Matlab代码(1)构建扫描次序表(修正小波树结构)
- IIS6.0服务器架站无法访问解决方案总结
- java的static import
- 程序员想创业首先要突破自己三关
- 数据结构-二叉树表达式快速求解法
- Hibernate提升性能
- 杀毒小谈
- cab打包详解