悬赏分:15 浏览:114 次
用如下语句过滤
private const string StrKeyWord = @"select|insert|delete|from|count(|drop table|update|truncate|asc(|mid(|char(|xp_cmdshell|exec master|netlocalgroup administrators|:|net user|""|or|and";
private const string StrRegex = @"[-|;|,|/|(|)|[|]|}|{|%|@|*|!|']";
public static bool CheckKeyWord(string sWord)
{
if (Regex.IsMatch(sWord, StrKeyWord, RegexOptions.IgnoreCase) || Regex.IsMatch(sWord, StrRegex))
return true;
return false;
}
在页面中
if(CheckKeyWord(TextBox1.Text))
{
--包含非法字符
}
else
{
}
时出错了
|
5天前 叶子绿了 : 为什么会出现这样子的错误,头大呀 |