예제 #1
0
 protected void OutputInlineReference(HtmlTagContextAttribute filterAttribute, AttachmentLink link, HtmlWriter writer)
 {
     AttachmentPolicy.Level attachmentLevel = this.GetAttachmentLevel(link);
     if (AttachmentPolicy.Level.Allow != attachmentLevel)
     {
         this.hasBlockedImagesInCurrentPass = true;
         this.hasBlockedInlineAttachments   = true;
         writer.WriteAttribute(filterAttribute.Id, "  ");
         return;
     }
     if (!this.isembeddedItem)
     {
         StringBuilder stringBuilder = new StringBuilder("/Microsoft-Server-ActiveSync?Cmd=GetAttachment&AttachmentName=");
         int           num           = 0;
         foreach (AttachmentLink attachmentLink in base.AttachmentLinks)
         {
             if (link.AttachmentId == attachmentLink.AttachmentId)
             {
                 break;
             }
             num++;
         }
         stringBuilder.AppendFormat(CultureInfo.InvariantCulture, "{0}:{1}", new object[]
         {
             this.itemId.ToBase64String(),
             num
         });
         writer.WriteAttribute(filterAttribute.Id, stringBuilder.ToString());
         return;
     }
     filterAttribute.WriteName();
     writer.WriteAttributeValue("cid:" + this.GetOrGenerateAttachContentId(link));
 }
예제 #2
0
        private void RestoreInlineAttachment(HtmlTagContextAttribute filterAttribute, HtmlTagContext context, HtmlWriter writer)
        {
            string text  = filterAttribute.Value;
            string value = filterAttribute.Value;

            text = HttpUtility.UrlDecode(text);
            if (!string.IsNullOrEmpty(text))
            {
                int num = value.IndexOf(OwaSafeHtmlCallbackBase.AttachmentBaseUrl, StringComparison.Ordinal);
                if (num != -1 && this.Item != null && this.Item.Id != null)
                {
                    if (AttachmentUtility.VerifyInlineAttachmentUrlValidity(value, this.item))
                    {
                        int            contentIdIndex;
                        string         contentId          = AttachmentUtility.ParseInlineAttachmentContentId(text, out contentIdIndex);
                        string         attachmentIdString = AttachmentUtility.ParseInlineAttachmentIdString(text, contentIdIndex);
                        AttachmentLink attachmentLink     = AttachmentUtility.GetAttachmentLink(attachmentIdString, contentId, this.item, this);
                        if (attachmentLink != null)
                        {
                            filterAttribute.WriteName();
                            writer.WriteAttributeValue(this.inlineHTMLAttachmentScheme + AttachmentUtility.GetOrGenerateAttachContentId(attachmentLink));
                            return;
                        }
                    }
                }
                else
                {
                    if (text.IndexOf(OwaSafeHtmlCallbackBase.blankImageFileName, StringComparison.Ordinal) != -1)
                    {
                        filterAttribute.WriteName();
                        writer.WriteAttributeValue(OwaSafeHtmlCallbackBase.DoubleBlank);
                        return;
                    }
                    filterAttribute.Write();
                }
            }
        }
        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;
            }
        }