The following snippet has worked for validating user entered html snippets for ages, now in past day it started rejecting everything.
public override bool IsValid(object value)
{
var isValid = true;
try
{
var doc = new XmlDocument();
doc.LoadXml(string.Format(@"
<!DOCTYPE html [<!ENTITY % xhtml-lat1 SYSTEM ""http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent"">
<!ENTITY % xhtml-special SYSTEM ""http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent"">
<!ENTITY % xhtml-symbol SYSTEM ""http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent"">
%xhtml-lat1;
%xhtml-special;
%xhtml-symbol;]>
<html>{0}</html>", value));
}
catch (XmlException)
{
isValid = false;
}
return isValid;
}