You can use some decompilation tool and see for yourself that there is no regular expression at all. It calls a static method CrossSiteScriptingValidation.IsDangerousString.
But perhaps you can use the Microsoft AntiXSS library to achieve the same. In any case, this is the method:
internal static bool IsDangerousString(string s, out int matchIndex)
{
matchIndex = 0;
int num1 = 0;
int num2 = s.IndexOfAny(CrossSiteScriptingValidation.startingChars, num1);
if (num2 < 0)
{
return false;
}
if (num2 == s.Length - 1)
{
return false;
}
matchIndex = num2;
char chars = s.get_Chars(num2);
if ((chars == 38 || chars == 60) && (CrossSiteScriptingValidation.IsAtoZ(s.get_Chars(num2 + 1)) || s.get_Chars(num2 + 1) == 33 || s.get_Chars(num2 + 1) == 47 || s.get_Chars(num2 + 1) == 63))
{
return true;
}
else
{
if (s.get_Chars(num2 + 1) == 35)
{
return true;
}
}
num1 = num2 + 1;
}
source
share