// Sanitizer MainEngine private static void MainEngine(StringBuilder elementString, IElement element) { if (element == null) { return; } else { elementString.Clear(); // clear the builder string inner = element.InnerHtml; string outer = element.OuterHtml; var pickParentRegex = RegexFactory.CreateRegex(RegexFactory.PickParentAttributes); string parentAttributes = pickParentRegex.Match(outer).Value; bool ParentHasStyle = parentAttributes.Contains("style"); // checks if style if (ParentHasStyle) { var pickParentStyleRegex = RegexFactory.CreateRegex(RegexFactory.PickStyle); string parentStyle = pickParentStyleRegex.Match(parentAttributes).Value; elementString.Append(parentStyle); } else { elementString.Append(parentAttributes); } } }
// Sanitizer Core private static void Core(string innerElement, StringBuilder elementString, bool ParentHasStyle) { //Check for the needed regexes bool innerHasColor = innerElement.Contains("color:"); bool innerHasBackGroundColor = innerElement.Contains("background-color:"); bool innerHasFontFamily = innerElement.Contains("font-family:"); // check the other Matches bool innerHasBold = innerElement.Contains("<b>"); bool innerHasUnderline = innerElement.Contains("<u>"); bool innerHasStrikeThrough = innerElement.Contains("<strike>"); bool innerHasItalics = innerElement.Contains("<i>"); // create the needed regexes if (innerElement.Contains("font-size:")) { var fontSizeRegex = RegexFactory.CreateRegex(RegexFactory.FontSize); string innerFontSize = fontSizeRegex.Match(innerElement).Value; } // math the element with all the regexes }