// Token: 0x06000128 RID: 296 RVA: 0x00004FB0 File Offset: 0x000031B0 internal static Stream GetFilteredStream(ConfigurationContextBase configurationContext, Stream inputStream, Charset charset, BlockStatus blockStatus) { HtmlToHtml htmlToHtml = new HtmlToHtml(); TextConvertersInternalHelpers.SetPreserveDisplayNoneStyle(htmlToHtml, true); WebBeaconFilterLevels filterWebBeaconsAndHtmlForms = configurationContext.FilterWebBeaconsAndHtmlForms; bool flag = filterWebBeaconsAndHtmlForms == WebBeaconFilterLevels.DisableFilter || blockStatus == BlockStatus.NoNeverAgain; Encoding encoding = null; if (charset != null && charset.TryGetEncoding(out encoding)) { htmlToHtml.DetectEncodingFromMetaTag = false; htmlToHtml.InputEncoding = encoding; htmlToHtml.OutputEncoding = encoding; } else { htmlToHtml.DetectEncodingFromMetaTag = true; htmlToHtml.InputEncoding = Encoding.ASCII; htmlToHtml.OutputEncoding = null; } htmlToHtml.FilterHtml = true; if (!flag) { htmlToHtml.HtmlTagCallback = new HtmlTagCallback(AttachmentUtilities.webBeaconFilter.ProcessTag); } return(new ConverterStream(inputStream, htmlToHtml, ConverterStreamAccess.Read)); }
public static string SanitizeHtml(string unsafeHtml) { if (string.IsNullOrEmpty(unsafeHtml)) { return(unsafeHtml); } string result; using (StringReader stringReader = new StringReader(unsafeHtml)) { using (StringWriter stringWriter = new StringWriter(CultureInfo.InvariantCulture)) { HtmlToHtml htmlToHtml = new HtmlToHtml(); TextConvertersInternalHelpers.SetPreserveDisplayNoneStyle(htmlToHtml, true); htmlToHtml.InputEncoding = Encoding.UTF8; htmlToHtml.OutputEncoding = Encoding.UTF8; htmlToHtml.FilterHtml = true; htmlToHtml.Convert(stringReader, stringWriter); result = stringWriter.ToString(); } } return(result); }