private static bool IsAttributeRedundant(HtmlTag tag, HtmlAttribute attribute)
{
string tagNameInLowercase = tag.NameInLowercase;
IList<HtmlAttribute> attributes = tag.Attributes;
string attributeNameInLowercase = attribute.NameInLowercase;
string attributeValue = attribute.Value;
string processedAttributeValue = attributeValue.Trim();
return (
(tagNameInLowercase == "script"
&& ((attributeNameInLowercase == "language" && processedAttributeValue.IgnoreCaseEquals("javascript"))
|| (attributeNameInLowercase == "charset" && attributes.All(a => a.NameInLowercase != "src"))))
|| (tagNameInLowercase == "link" && attributeNameInLowercase == "charset" && attributes.Any(
a => a.NameInLowercase == "rel" && a.Value.Trim().IgnoreCaseEquals("stylesheet")))
|| (tagNameInLowercase == "form" && attributeNameInLowercase == "method"
&& processedAttributeValue.IgnoreCaseEquals("get"))
|| (tagNameInLowercase == "input" && attributeNameInLowercase == "type"
&& processedAttributeValue.IgnoreCaseEquals("text"))
|| (tagNameInLowercase == "a" && attributeNameInLowercase == "name" && attributes.Any(
a => a.NameInLowercase == "id" && a.Value == attributeValue))
|| (tagNameInLowercase == "area" && attributeNameInLowercase == "shape"
&& processedAttributeValue.IgnoreCaseEquals("rect"))
);
}