public void Clean(NameValueCollection collection, IXssConfigurationHandler configuration, EncoderType encoderType = EncoderType.AutoDetect) { if (string.IsNullOrWhiteSpace(configuration.ControlRegex)) { _xssDetectRegex = new Regex(_regexHelper.XssPattern, RegexOptions.IgnoreCase); } else { try { _xssDetectRegex = new Regex(HttpUtility.HtmlDecode(configuration.ControlRegex), RegexOptions.IgnoreCase); } catch { _xssDetectRegex = new Regex(_regexHelper.XssPattern, RegexOptions.IgnoreCase); } } PropertyInfo readonlyProperty = _reflectionHelper.MakeWritable(collection); for (int i = 0; i < collection.Count; i++) { if (string.IsNullOrWhiteSpace(collection[i])) { continue; } IterateCleanUp(encoderType, collection, i); } readonlyProperty.SetValue(collection, true, null); }