// Token: 0x06002FC1 RID: 12225 RVA: 0x00115CE8 File Offset: 0x00113EE8 internal static void ConvertAndOutputBody(TextWriter output, Body body, Markup markup, OwaSafeHtmlCallbackBase callBack) { try { BodyReadConfiguration bodyReadConfiguration = null; switch (markup) { case Markup.Html: bodyReadConfiguration = new BodyReadConfiguration(BodyFormat.TextHtml, "utf-8"); bodyReadConfiguration.SetHtmlOptions(HtmlStreamingFlags.FilterHtml, callBack); break; case Markup.PlainText: bodyReadConfiguration = new BodyReadConfiguration(BodyFormat.TextPlain, "utf-8"); break; } if (bodyReadConfiguration != null) { using (TextReader textReader = body.OpenTextReader(bodyReadConfiguration)) { BodyConversionUtilities.HtmlEncodeAndOutputBody(output, textReader); } } } catch (InvalidCharsetException innerException) { throw new OwaBodyConversionFailedException("Body Conversion Failed", innerException); } catch (ConversionFailedException innerException2) { throw new OwaBodyConversionFailedException("Body Conversion Failed", innerException2); } }
// Token: 0x06001397 RID: 5015 RVA: 0x00070BF8 File Offset: 0x0006EDF8 public static Stream ConvertHtmlStream(Item item, long truncationSizeByChars, out long totalDataSize, out IList <AttachmentLink> attachmentLinks) { SafeHtmlCallback safeHtmlCallback = new SafeHtmlCallback(item); bool flag = truncationSizeByChars == -1L; BodyReadConfiguration bodyReadConfiguration; if (flag) { bodyReadConfiguration = new BodyReadConfiguration(Microsoft.Exchange.Data.Storage.BodyFormat.TextHtml, "utf-8"); bodyReadConfiguration.SetHtmlOptions(HtmlStreamingFlags.FilterHtml, safeHtmlCallback); } else { bodyReadConfiguration = new BodyReadConfiguration(Microsoft.Exchange.Data.Storage.BodyFormat.TextHtml, "utf-8"); bodyReadConfiguration.SetHtmlOptions(HtmlStreamingFlags.FilterHtml, safeHtmlCallback, new int?(1024)); } AirSyncStream airSyncStream = new AirSyncStream(); Body body = null; if (BodyConversionUtilities.IsMessageRestrictedAndDecoded(item)) { body = ((RightsManagedMessageItem)item).ProtectedBody; } else { body = item.Body; } uint streamHash; using (Stream stream = body.OpenReadStream(bodyReadConfiguration)) { StreamHelper.CopyStream(stream, airSyncStream, Encoding.UTF8, (int)truncationSizeByChars, true, out streamHash); } airSyncStream.StreamHash = (int)streamHash; totalDataSize = ((truncationSizeByChars < 0L || airSyncStream.Length < truncationSizeByChars) ? airSyncStream.Length : body.Size); attachmentLinks = safeHtmlCallback.AttachmentLinks; return(airSyncStream); }
// Token: 0x06000622 RID: 1570 RVA: 0x00030C24 File Offset: 0x0002EE24 public static void ConvertAndOutputBody(TextWriter output, Body body, Markup markup, OwaSafeHtmlCallbackBase callBack, bool isComposeBody) { string bodyString = string.Empty; BodyReadConfiguration bodyReadConfiguration = null; try { switch (markup) { case Markup.Html: bodyReadConfiguration = new BodyReadConfiguration(BodyFormat.TextHtml); bodyReadConfiguration.SetHtmlOptions(HtmlStreamingFlags.FilterHtml | HtmlStreamingFlags.Fragment, callBack); break; case Markup.PlainText: bodyReadConfiguration = new BodyReadConfiguration(BodyFormat.TextPlain); break; } if (bodyReadConfiguration != null) { using (TextReader textReader = body.OpenTextReader(bodyReadConfiguration)) { bodyString = textReader.ReadToEnd(); } } BodyConversionUtilities.RenderBodyContent(output, bodyString, markup, isComposeBody); } catch (InvalidCharsetException innerException) { throw new OwaBodyConversionFailedException("Body Conversion Failed", innerException); } catch (ConversionFailedException innerException2) { throw new OwaBodyConversionFailedException("Body Conversion Failed", innerException2); } }
protected void ProcessHtmlUrlTag(HtmlTagContextAttribute filterAttribute, HtmlTagContext context, HtmlWriter writer) { OwaSafeHtmlOutboundCallbacks.TypeOfUrl typeOfUrl = this.GetTypeOfUrl(filterAttribute.Value, filterAttribute.Id); string text; if (typeOfUrl == OwaSafeHtmlOutboundCallbacks.TypeOfUrl.Unknown || typeOfUrl == OwaSafeHtmlOutboundCallbacks.TypeOfUrl.Local) { if (this.baseRef == null && this.isConversationsOrUnknownType && !this.triedLoadingBaseHref) { OwaLightweightHtmlCallback owaLightweightHtmlCallback = new OwaLightweightHtmlCallback(); using (Item item = Utilities.GetItem <Item>(this.owaContext.UserContext, this.itemId, new PropertyDefinition[0])) { BodyReadConfiguration bodyReadConfiguration = new BodyReadConfiguration(BodyFormat.TextHtml, "utf-8"); bodyReadConfiguration.SetHtmlOptions(HtmlStreamingFlags.FilterHtml, owaLightweightHtmlCallback); Body body = item.Body; if (this.owaContext.UserContext.IsIrmEnabled) { Utilities.IrmDecryptIfRestricted(item, this.owaContext.UserContext, true); if (Utilities.IsIrmRestrictedAndDecrypted(item)) { body = ((RightsManagedMessageItem)item).ProtectedBody; } } using (TextReader textReader = body.OpenTextReader(bodyReadConfiguration)) { int num = 5000; char[] buffer = new char[num]; textReader.Read(buffer, 0, num); } } this.baseRef = owaLightweightHtmlCallback.BaseRef; this.triedLoadingBaseHref = true; } text = this.GetAbsoluteUrl(filterAttribute.Value, filterAttribute.Id); typeOfUrl = this.GetTypeOfUrl(text, filterAttribute.Id); } else { text = filterAttribute.Value; } switch (typeOfUrl) { case OwaSafeHtmlOutboundCallbacks.TypeOfUrl.Local: if (this.owaContext.UserContext.BrowserType != BrowserType.Safari && !this.owaContext.UserContext.IsBasicExperience && !this.isConversations) { writer.WriteAttribute(filterAttribute.Id, OwaSafeHtmlCallbackBase.JSLocalLink + OwaSafeHtmlCallbackBase.JSMethodPrefix + filterAttribute.Value.Substring(1) + OwaSafeHtmlCallbackBase.JSMethodSuffix); return; } filterAttribute.Write(); return; case OwaSafeHtmlOutboundCallbacks.TypeOfUrl.Trusted: filterAttribute.Write(); this.hasFoundNonLocalUrlInCurrentPass = true; return; case OwaSafeHtmlOutboundCallbacks.TypeOfUrl.Redirection: filterAttribute.WriteName(); writer.WriteAttributeValue(Redir.BuildRedirUrl(this.owaContext.UserContext, text)); this.hasFoundNonLocalUrlInCurrentPass = true; return; case OwaSafeHtmlOutboundCallbacks.TypeOfUrl.Unknown: writer.WriteAttribute(filterAttribute.Id, OwaSafeHtmlOutboundCallbacks.BlockedUrlPageValue); this.hasFoundNonLocalUrlInCurrentPass = true; return; default: return; } }