?? common.cs
字號:
?using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
/// <summary>
/// Common 的摘要說明
/// </summary>
public class Common
{
public Common()
{
//
// TODO: 在此處添加構(gòu)造函數(shù)邏輯
//
}
public static string InputText(string inputString, int maxLength)
{ //過濾JAVA腳本和html
System.Text.RegularExpressions.Regex regex1 = new System.Text.RegularExpressions.Regex(@"<script[/s/S]+</script *>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex2 = new System.Text.RegularExpressions.Regex(@" href *= *[/s/S]*script *:", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex3 = new System.Text.RegularExpressions.Regex(@" on[/s/S]*=", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex4 = new System.Text.RegularExpressions.Regex(@"<iframe[/s/S]+</iframe *>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex5 = new System.Text.RegularExpressions.Regex(@"<frameset[/s/S]+</frameset *>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
inputString = regex1.Replace(inputString, ""); //過濾<script></script>標(biāo)記
inputString = regex2.Replace(inputString, ""); //過濾href="/u/javascript: ";(<A>) 屬性
inputString = regex3.Replace(inputString, " _disibledevent="); //過濾其它控件的on...事件
inputString = regex4.Replace(inputString, ""); //過濾iframe
inputString = regex5.Replace(inputString, ""); //過濾frameset
//過濾危險字符。。。。
StringBuilder retVal = new StringBuilder();
if ((inputString != null) && (inputString != String.Empty))
{
inputString = inputString.Trim();
if (inputString.Length > maxLength)
{
inputString = inputString.Substring(0, maxLength);
}
for (int i = 0; i < inputString.Length; i++)
{
switch (inputString)
{
case "%":
retVal.Append("");
break;
case "/":
retVal.Append("");
break;
case "*":
retVal.Append("");
break;
case "-":
retVal.Append("");
break;
case "\"":
retVal.Append(""");
break;
case "<":
retVal.Append("<");
break;
case ">":
retVal.Append(">");
break;
default:
retVal.Append(inputString);
break;
}
}
// Replace single quotes with white space
retVal.Replace("'", " ");
}
return retVal.ToString();
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -