Нужно вернуть строку: http://kbyte.ru?key1=1&key2=2, удалив строку, содержащую CSS – атаку. Как это сделать?
У меня есть некий код:
public void GetParamsCheckForCSS(HttpRequest Request)
{
string OriginalPath = Request.Path.ToLower();
string PathInfo = Request.PathInfo.ToLower();
NameValueCollection Query_Collection = Request.QueryString;
List<string> ParamList = new List<string>();
if (Query_Collection.Count > 0)
{
string[] QueryKeys = Query_Collection.AllKeys;
foreach (string k in QueryKeys)
{
ParamList.Add((string)Query_Collection[k]);
}
int BadParamIndex = 0;
Regex SearchScript = new Regex("[^<script>].*[$</script>]",
RegexOptions.IgnoreCase
| RegexOptions.CultureInvariant
| RegexOptions.IgnorePatternWhitespace
);
foreach (string p in ParamList)
{
string c = HttpUtility.UrlDecode(p);
if (SearchScript.Matches(c).Count > 0)
{
ParamList.Remove(p);
}
BadParamIndex++;
}
HttpContext.Current.RewritePath(OriginalPath, PathInfo, "x=");
}
}

