All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
此方法用于确认用户输入的不是恶意信息_.net资料_编程技术

Writer: aaa Article type: Programming skills(编程技巧) Time: 2013/12/13 9:43:51 Browse times: 244 Comment times: 0

此方法用于确认用户输入的不是恶意信息_.net资料_编程技术


Head photo

Go homepage
Upload pictures
Write articles

此方法用于确认用户输入的不是恶意信息_.net资料_编程技术-你的首页-uuhomepage.com







参照petshop 4.0
///
/// 此方法用于确认用户输入的不是恶意信息
///

/// 用户输入信息
/// 输入的最大长度
/// 处理后的输入信息
public static string InputText(string text, int maxLength) {
text = text.Trim();
if (string.IsNullOrEmpty(text))
return string.Empty;
if (text.Length > maxLength)
text = text.Substring(0, maxLength);
//将网页中非法和有攻击性的符号替换掉,以防sql注入!返回正常数据
text = Regex.Replace(text, "[\\s]{2,}", " "); // 2个或以上的空格
text = Regex.Replace(text, "(<[b|B][r|R]/*>)+|(<[p|P](.|\\n)*?>)", "\n"); //
html换行符
text = Regex.Replace(text, "(\\s*&[n|N][b|B][s|S][p|P];\\s*)+", " "); //&nbsp; html空格符
text = Regex.Replace(text, "<(.|\\n)*?>", string.Empty); // 任何其他的标签
text = text.Replace("'", "''");// 单引号
return text;
}









关键词:
推荐给好友】【关闭

















最新五条评论



查看全部评论



评论总数 0




































您的评论
















用户名:


新注册


密 码:





匿名:




































·用户发表意见仅代表其个人意见,并且承担一切因发表内容引起的纠纷和责任



·本站管理人员有权在不通知用户的情况下删除不符合规定的评论信息或留做证据



·请客观的评价您所看到的资讯,提倡就事论事,杜绝漫骂和人身攻击等不文明行为





































There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.