示例#1
0
 // Token: 0x06001001 RID: 4097 RVA: 0x000637CC File Offset: 0x000619CC
 public static void WriteLocalizedStyleIntoHeadForPlainTextBody(Item item, TextWriter writer, string styleElement)
 {
     if (item == null)
     {
         throw new ArgumentNullException("item");
     }
     if (writer == null)
     {
         throw new ArgumentNullException("writer");
     }
     if (styleElement == null)
     {
         throw new ArgumentNullException("styleElement");
     }
     if (item.Body.Format == BodyFormat.TextPlain)
     {
         writer.Write("<style>");
         writer.Write(styleElement);
         writer.Write(OwaPlainTextStyle.GetStyleFromCharset(item));
         writer.Write("</style>");
     }
 }
        public override void ProcessTag(HtmlTagContext context, HtmlWriter writer)
        {
            bool           flag           = false;
            bool           flag2          = false;
            bool           flag3          = false;
            bool           flag4          = false;
            string         text           = null;
            string         text2          = null;
            string         text3          = null;
            AttachmentLink attachmentLink = null;

            if (context.TagId == HtmlTagId.Link)
            {
                context.DeleteTag();
                return;
            }
            if (context.TagId == HtmlTagId.Head)
            {
                if (this.owaContext.UserContext.IsBasicExperience || this.bodyFormat != BodyFormat.TextPlain)
                {
                    context.WriteTag(true);
                    return;
                }
                if (!context.IsEndTag)
                {
                    context.WriteTag(true);
                    context.InvokeCallbackForEndTag();
                    return;
                }
                writer.WriteStartTag(HtmlTagId.Style);
                writer.WriteText("div.PlainText ");
                if (ObjectClass.IsSmsMessage(this.objectClass))
                {
                    writer.WriteText(OwaPlainTextStyle.GetStyleFromUserOption(this.owaContext.UserContext.UserOptions));
                }
                else
                {
                    writer.WriteText(OwaPlainTextStyle.GetStyleFromCharset(this.charSet));
                }
                writer.WriteEndTag(HtmlTagId.Style);
                context.WriteTag(true);
                return;
            }
            else
            {
                if (this.isOutputFragment && context.TagId == HtmlTagId.Form)
                {
                    context.DeleteTag();
                    return;
                }
                if (context.TagId == HtmlTagId.Form || (!this.isOutputFragment && OwaSafeHtmlOutboundCallbacks.IsFormElementTag(context.TagId)))
                {
                    this.ProcessUnfragFormTagContext(context, writer);
                    return;
                }
                if (context.TagId == HtmlTagId.Base)
                {
                    foreach (HtmlTagContextAttribute attribute in context.Attributes)
                    {
                        if (OwaSafeHtmlCallbackBase.IsBaseTag(context.TagId, attribute))
                        {
                            string value = attribute.Value;
                            this.baseRef = Utilities.TryParseUri(value);
                            break;
                        }
                    }
                    return;
                }
                foreach (HtmlTagContextAttribute filterAttribute in context.Attributes)
                {
                    if (filterAttribute.Id == HtmlAttributeId.Src || filterAttribute.Id == HtmlAttributeId.Href)
                    {
                        if (context.TagId == HtmlTagId.Img && string.IsNullOrEmpty(filterAttribute.Value))
                        {
                            return;
                        }
                        if (string.CompareOrdinal(filterAttribute.Value, this.inlineRTFattachmentScheme) == 0 || filterAttribute.Value.StartsWith(this.inlineHTMLAttachmentScheme, StringComparison.OrdinalIgnoreCase))
                        {
                            attachmentLink = this.IsInlineImage(filterAttribute);
                            if (attachmentLink == null)
                            {
                                return;
                            }
                            if (context.TagId != HtmlTagId.Img)
                            {
                                writer.WriteEmptyElementTag(HtmlTagId.Img);
                                this.OutputInlineReference(filterAttribute, context, attachmentLink, writer);
                                context.DeleteTag(false);
                                context.DeleteInnerContent();
                                return;
                            }
                            flag2 = true;
                            break;
                        }
                        else
                        {
                            if (string.CompareOrdinal(filterAttribute.Value, this.embeddedRTFImage) == 0)
                            {
                                this.hasRtfEmbeddedImages = true;
                                break;
                            }
                            break;
                        }
                    }
                }
                context.WriteTag();
                foreach (HtmlTagContextAttribute htmlTagContextAttribute in context.Attributes)
                {
                    if (!this.isOutputFragment || htmlTagContextAttribute.Id != HtmlAttributeId.Name || !OwaSafeHtmlOutboundCallbacks.IsFormElementTag(context.TagId))
                    {
                        if (htmlTagContextAttribute.Id == HtmlAttributeId.UseMap)
                        {
                            this.ProcessUseMapAttribute(htmlTagContextAttribute, context, writer);
                        }
                        else if (OwaSafeHtmlCallbackBase.IsUrlTag(context.TagId, htmlTagContextAttribute))
                        {
                            if (!flag)
                            {
                                this.ProcessHtmlUrlTag(htmlTagContextAttribute, context, writer);
                                flag = true;
                            }
                        }
                        else if (OwaSafeHtmlCallbackBase.IsImageTag(context.TagId, htmlTagContextAttribute))
                        {
                            if (htmlTagContextAttribute.Id == HtmlAttributeId.Src && attachmentLink != null)
                            {
                                this.OutputInlineReference(htmlTagContextAttribute, context, attachmentLink, writer);
                            }
                            else
                            {
                                if ((htmlTagContextAttribute.Id != HtmlAttributeId.Src || flag2) && (htmlTagContextAttribute.Id != HtmlAttributeId.DynSrc || flag3) && (htmlTagContextAttribute.Id != HtmlAttributeId.LowSrc || flag4))
                                {
                                    continue;
                                }
                                this.ProcessImageTag(htmlTagContextAttribute, context, writer);
                            }
                            if (htmlTagContextAttribute.Id == HtmlAttributeId.Src)
                            {
                                flag2 = true;
                            }
                            else if (htmlTagContextAttribute.Id == HtmlAttributeId.DynSrc)
                            {
                                flag3 = true;
                            }
                            else if (htmlTagContextAttribute.Id == HtmlAttributeId.LowSrc)
                            {
                                flag4 = true;
                            }
                        }
                        else if (OwaSafeHtmlCallbackBase.IsBackgroundAttribute(htmlTagContextAttribute))
                        {
                            if (this.isOutputFragment && context.TagId == HtmlTagId.Div)
                            {
                                attachmentLink = this.IsInlineImage(htmlTagContextAttribute);
                                if (attachmentLink != null)
                                {
                                    AttachmentPolicy.Level attachmentLevel = this.GetAttachmentLevel(attachmentLink);
                                    if (AttachmentPolicy.Level.Allow == attachmentLevel)
                                    {
                                        writer.WriteAttribute(HtmlAttributeId.Style, "background:url('" + this.GetInlineReferenceUrl(attachmentLevel, attachmentLink, writer) + "');");
                                    }
                                }
                            }
                            else
                            {
                                this.ProcessImageTag(htmlTagContextAttribute, context, writer);
                            }
                        }
                        else if (!OwaSafeHtmlOutboundCallbacks.IsTargetTagInAnchor(context.TagId, htmlTagContextAttribute))
                        {
                            if (OwaSafeHtmlCallbackBase.IsSanitizingAttribute(htmlTagContextAttribute))
                            {
                                if (htmlTagContextAttribute.Id == HtmlAttributeId.Border)
                                {
                                    text = htmlTagContextAttribute.Value;
                                }
                                else if (htmlTagContextAttribute.Id == HtmlAttributeId.Height)
                                {
                                    text2 = htmlTagContextAttribute.Value;
                                }
                                else if (htmlTagContextAttribute.Id == HtmlAttributeId.Width)
                                {
                                    text3 = htmlTagContextAttribute.Value;
                                }
                            }
                            else
                            {
                                htmlTagContextAttribute.Write();
                            }
                        }
                    }
                }
                if (!string.IsNullOrEmpty(text2) && !string.IsNullOrEmpty(text3) && this.hasBlockedImagesInCurrentPass)
                {
                    OwaSafeHtmlOutboundCallbacks.SanitizeImage(writer, text, text2, text3);
                }
                else if (!this.hasBlockedImagesInCurrentPass)
                {
                    if (!string.IsNullOrEmpty(text2))
                    {
                        writer.WriteAttribute(HtmlAttributeId.Height, text2);
                    }
                    if (!string.IsNullOrEmpty(text3))
                    {
                        writer.WriteAttribute(HtmlAttributeId.Width, text3);
                    }
                    if (!string.IsNullOrEmpty(text))
                    {
                        writer.WriteAttribute(HtmlAttributeId.Border, text);
                    }
                }
                if (this.hasFoundNonLocalUrlInCurrentPass)
                {
                    if (this.owaContext.UserContext.IsBasicExperience)
                    {
                        if (!this.hasFoundMailToUrlInCurrentPass || this.openMailtoInNewWindow)
                        {
                            this.WriteSafeTargetBlank(writer);
                        }
                    }
                    else
                    {
                        this.WriteSafeTargetBlank(writer);
                    }
                }
                this.hasBlockedImagesInCurrentPass    = false;
                this.hasFoundNonLocalUrlInCurrentPass = false;
                this.hasFoundMailToUrlInCurrentPass   = false;
                return;
            }
        }
        internal static void RenderError(OwaContext owaContext, TextWriter writer)
        {
            if (owaContext == null)
            {
                throw new ArgumentNullException("owaContext");
            }
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }
            if (owaContext.ErrorInformation == null)
            {
                throw new ArgumentNullException("owaContext", "owaContext.ErrorInformation is null");
            }
            owaContext.HttpContext.Response.Clear();
            writer.Write("<meta http-equiv=\"Content-Type\" content=\"text/html; CHARSET=utf-8\">");
            writer.Write("<body style=\"background-color:#FFEFB2;font-size:11pt;\"");
            if (owaContext.SessionContext != null && owaContext.SessionContext.IsRtl)
            {
                writer.Write(" dir=\"rtl\"");
            }
            writer.Write(">");
            string value = string.Format("{{font-family:{0};}}", Utilities.GetDefaultFontName());

            writer.Write("<style>");
            writer.Write("BODY");
            if (Culture.GetUserCulture().LCID == 5124 || Culture.GetUserCulture().LCID == 1028 || Culture.GetUserCulture().LCID == 3076)
            {
                writer.Write(OwaPlainTextStyle.GetStyleFromCharset("big5"));
            }
            else if (Culture.GetUserCulture().LCID == 2052 || Culture.GetUserCulture().LCID == 4100)
            {
                writer.Write(OwaPlainTextStyle.GetStyleFromCharset("gb2312"));
            }
            else if (Culture.GetUserCulture().LCID == 1041)
            {
                writer.Write(OwaPlainTextStyle.GetStyleFromCharset("iso-2022-jp"));
            }
            else if (Culture.GetUserCulture().LCID == 1042)
            {
                writer.Write(OwaPlainTextStyle.GetStyleFromCharset("iso-2022-kr"));
            }
            else
            {
                writer.Write(value);
            }
            writer.Write("</style>");
            Utilities.HtmlEncode(owaContext.ErrorInformation.Message, writer);
            if (owaContext.ErrorInformation.OwaEventHandlerErrorCode == OwaEventHandlerErrorCode.WebPartFirstAccessError)
            {
                writer.Write("<br><a target=_blank href=\"");
                writer.Write(Utilities.HtmlEncode(OwaUrl.ApplicationRoot.GetExplicitUrl(owaContext)));
                writer.Write("\">");
                writer.Write(LocalizedStrings.GetHtmlEncoded(675765292));
                writer.Write("</a>");
            }
            else if (owaContext.ErrorInformation.OwaEventHandlerErrorCode == OwaEventHandlerErrorCode.WebPartTaskFolderError || owaContext.ErrorInformation.OwaEventHandlerErrorCode == OwaEventHandlerErrorCode.ErrorEarlyBrowserOnPublishedCalendar || owaContext.ErrorInformation.OwaEventHandlerErrorCode == OwaEventHandlerErrorCode.WebPartCalendarFolderError || owaContext.ErrorInformation.OwaEventHandlerErrorCode == OwaEventHandlerErrorCode.WebPartAccessPublicFolderViaOwaBasicError)
            {
                string value2 = Utilities.HtmlEncode(Globals.SupportedBrowserHelpUrl);
                writer.Write("<br><a target=\"_blank\" href=\"");
                writer.Write(value2);
                writer.Write("\">");
                writer.Write(value2);
                writer.Write("</a>");
            }
            if (owaContext.ErrorInformation.MessageDetails != null)
            {
                writer.Write("<br>");
                Utilities.HtmlEncode(owaContext.ErrorInformation.MessageDetails, writer);
            }
            writer.Write("</body>");
            owaContext.HttpContext.Response.ContentType = Utilities.GetContentTypeString(OwaEventContentType.Html);
            owaContext.HttpContext.Response.AppendHeader("X-OWA-EventResult", "1");
        }
示例#4
0
 // Token: 0x06001002 RID: 4098 RVA: 0x0006383A File Offset: 0x00061A3A
 private static string GetStyleFromCharset(Item item)
 {
     return(OwaPlainTextStyle.GetStyleFromCharset(item.Body.Charset));
 }
示例#5
0
 // Token: 0x06001005 RID: 4101 RVA: 0x00063960 File Offset: 0x00061B60
 internal static string GetStyleFromUserOption(UserOptions options)
 {
     return('{' + OwaPlainTextStyle.GetStyleContentFromUserOption(options, false) + '}');
 }