예제 #1
0
        protected void ProcessHtmlUrlTag(HtmlTagContextAttribute filterAttribute, HtmlWriter writer)
        {
            string         value          = filterAttribute.Value;
            AttachmentLink attachmentLink = this.IsInlineReference(value);

            if (attachmentLink != null)
            {
                this.OutputInlineReference(filterAttribute, attachmentLink, writer);
                return;
            }
            SafeHtmlCallback.TypeOfUrl typeOfUrl = SafeHtmlCallback.GetTypeOfUrl(filterAttribute.Value, filterAttribute.Id);
            if (typeOfUrl == SafeHtmlCallback.TypeOfUrl.Redirection)
            {
                filterAttribute.Write();
                this.hasFoundRedirUrlInCurrentPass = true;
                return;
            }
            if (typeOfUrl == SafeHtmlCallback.TypeOfUrl.Trusted || typeOfUrl == SafeHtmlCallback.TypeOfUrl.Local)
            {
                filterAttribute.Write();
                return;
            }
            if (typeOfUrl == SafeHtmlCallback.TypeOfUrl.Unknown)
            {
                writer.WriteAttribute(filterAttribute.Id, "  ");
            }
        }
        protected AttachmentLink IsInlineImage(HtmlTagContextAttribute filterAttribute)
        {
            AttachmentLink attachmentLink = this.IsInlineReference(filterAttribute.Value);

            if (attachmentLink != null)
            {
                string text;
                if (attachmentLink.AttachmentType == AttachmentType.Ole)
                {
                    text = "image/jpeg";
                }
                else
                {
                    text = attachmentLink.ContentType;
                    if (string.Compare(text, "image/tiff", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        return(null);
                    }
                }
                if (text.StartsWith("image/", StringComparison.OrdinalIgnoreCase))
                {
                    this.hasInlineImages = true;
                    return(attachmentLink);
                }
            }
            return(null);
        }
 public override void ProcessTag(HtmlTagContext context, HtmlWriter writer)
 {
     if (context == null)
     {
         throw new ArgumentNullException("context");
     }
     if (writer == null)
     {
         throw new ArgumentNullException("writer");
     }
     if (OwaSafeHtmlWebReadyCallbacks.IsStyleSheetLinkTag(context))
     {
         context.WriteTag();
         using (HtmlTagContext.AttributeCollection.Enumerator enumerator = context.Attributes.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 HtmlTagContextAttribute htmlTagContextAttribute = enumerator.Current;
                 if (htmlTagContextAttribute.Id == HtmlAttributeId.Href)
                 {
                     writer.WriteAttribute(htmlTagContextAttribute.Id, this.urlPrefix + htmlTagContextAttribute.Value);
                 }
                 else
                 {
                     htmlTagContextAttribute.Write();
                 }
             }
             return;
         }
     }
     base.ProcessTag(context, writer);
 }
예제 #4
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));
 }
 protected override void ProcessUseMapAttribute(HtmlTagContextAttribute filterAttribute, HtmlTagContext context, HtmlWriter writer)
 {
     if (context.TagId == HtmlTagId.Img)
     {
         filterAttribute.Write();
         return;
     }
     base.ProcessTag(context, writer);
 }
        // Token: 0x060010C4 RID: 4292 RVA: 0x00066E38 File Offset: 0x00065038
        protected override void ProcessImageTag(HtmlTagContextAttribute filterAttribute, HtmlTagContext context, HtmlWriter writer)
        {
            AttachmentLink attachmentLink = base.IsInlineImage(filterAttribute);

            if (attachmentLink != null)
            {
                base.OutputInlineReference(filterAttribute, context, attachmentLink, writer);
                return;
            }
            if (base.IsSafeUrl(filterAttribute.Value, filterAttribute.Id))
            {
                filterAttribute.Write();
            }
        }
예제 #7
0
        private static void RestoreUrl(HtmlTagContextAttribute filterAttribute, HtmlWriter writer)
        {
            string value = filterAttribute.Value;

            if (!string.IsNullOrEmpty(value))
            {
                int    num  = value.IndexOf("redir.aspx?", StringComparison.Ordinal);
                string text = null;
                if (num != -1)
                {
                    string text2 = value.Substring(num + "redir.aspx?".Length);
                    if (text2.StartsWith("URL=", StringComparison.Ordinal))
                    {
                        text = text2.Substring("URL=".Length);
                    }
                    else
                    {
                        bool   legacyFormat = true;
                        string text3        = null;
                        if (text2.StartsWith("SURL", StringComparison.Ordinal))
                        {
                            text3 = text2.Substring("SURL".Length);
                        }
                        else if (text2.StartsWith("REF", StringComparison.Ordinal))
                        {
                            text3        = text2.Substring("REF".Length);
                            legacyFormat = false;
                        }
                        if (text3 != null)
                        {
                            text = CryptoMessage.ExtractUrl(text3, legacyFormat);
                        }
                    }
                }
                else
                {
                    num = OwaSafeHtmlCallbackBase.JSLocalLink.Length + OwaSafeHtmlCallbackBase.JSMethodPrefix.Length;
                    if (value.StartsWith(OwaSafeHtmlCallbackBase.JSLocalLink + OwaSafeHtmlCallbackBase.JSMethodPrefix, StringComparison.Ordinal) && value.EndsWith(OwaSafeHtmlCallbackBase.JSMethodSuffix, StringComparison.Ordinal))
                    {
                        text = OwaSafeHtmlCallbackBase.LocalUrlPrefix + value.Substring(num, value.Length - OwaSafeHtmlCallbackBase.JSMethodSuffix.Length - num);
                    }
                }
                if (text != null)
                {
                    writer.WriteAttribute(filterAttribute.Id, HttpUtility.UrlDecode(text));
                    return;
                }
                filterAttribute.Write();
            }
        }
        protected virtual void ProcessImageTag(HtmlTagContextAttribute filterAttribute, HtmlTagContext context, HtmlWriter writer)
        {
            AttachmentLink attachmentLink = this.IsInlineImage(filterAttribute);

            if (attachmentLink != null)
            {
                this.OutputInlineReference(filterAttribute, context, attachmentLink, writer);
                return;
            }
            if (this.IsSafeUrl(filterAttribute.Value, filterAttribute.Id))
            {
                this.hasBlockedImagesInCurrentPass = true;
                this.hasBlockedImages = true;
                writer.WriteAttribute(filterAttribute.Id, OwaSafeHtmlCallbackBase.blankImageFileName);
            }
        }
예제 #9
0
        protected void ProcessImageTag(HtmlTagContextAttribute filterAttribute, HtmlTagContext context, HtmlWriter writer)
        {
            AirSyncDiagnostics.Assert(context != null);
            string         value          = filterAttribute.Value;
            AttachmentLink attachmentLink = this.IsInlineReference(value);

            if (attachmentLink != null)
            {
                this.OutputInlineReference(filterAttribute, attachmentLink, writer);
                return;
            }
            if (SafeHtmlCallback.IsSafeUrl(filterAttribute.Value, filterAttribute.Id))
            {
                filterAttribute.Write();
            }
        }
예제 #10
0
        protected override void ProcessImageTag(HtmlTagContextAttribute filterAttribute, HtmlTagContext context, HtmlWriter writer)
        {
            AttachmentLink attachmentLink = base.IsInlineImage(filterAttribute);

            if (attachmentLink != null)
            {
                base.OutputInlineReference(filterAttribute, context, attachmentLink, writer);
                return;
            }
            if (base.IsSafeUrl(filterAttribute.Value, filterAttribute.Id))
            {
                this.hasBlockedImagesInCurrentPass = true;
                this.hasBlockedImages = true;
                string value = this.owaContext.UserContext.GetBlankPage(Utilities.PremiumScriptPath) + "#" + OwaSafeHtmlConversationsCallbacks.UrlDelimiter + filterAttribute.Value;
                writer.WriteAttribute(HtmlAttributeId.Src, value);
            }
        }
        protected void OutputInlineReference(HtmlTagContextAttribute filterAttribute, HtmlTagContext context, AttachmentLink imageAttachmentLink, HtmlWriter writer)
        {
            AttachmentPolicy.Level attachmentLevel = this.GetAttachmentLevel(imageAttachmentLink);
            if (AttachmentPolicy.Level.Allow == attachmentLevel && filterAttribute.Id == HtmlAttributeId.Href)
            {
                writer.WriteAttribute(HtmlAttributeId.Src, this.GetInlineReferenceUrl(attachmentLevel, imageAttachmentLink, writer));
                return;
            }
            string value;

            if (this.owaContext.ShouldDeferInlineImages)
            {
                value = this.owaContext.UserContext.GetThemeFileUrl(ThemeFileId.Clear1x1) + "#" + OwaSafeHtmlOutboundCallbacks.DeferImageUrlDelimiter + this.GetInlineReferenceUrl(attachmentLevel, imageAttachmentLink, writer);
            }
            else
            {
                value = this.GetInlineReferenceUrl(attachmentLevel, imageAttachmentLink, writer);
            }
            writer.WriteAttribute(filterAttribute.Id, value);
        }
예제 #12
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();
                }
            }
        }
예제 #13
0
 protected static bool IsBaseTag(HtmlTagId tagId, HtmlTagContextAttribute attribute)
 {
     return(tagId == HtmlTagId.Base && attribute.Id == HtmlAttributeId.Href);
 }
 protected override void ProcessImageTag(HtmlTagContextAttribute filterAttribute, HtmlTagContext context, HtmlWriter writer)
 {
     writer.WriteAttribute(filterAttribute.Id, this.urlPrefix + filterAttribute.Value);
 }
        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;
            }
        }
예제 #16
0
 protected static bool IsUrlTag(HtmlTagId tagId, HtmlTagContextAttribute attribute)
 {
     return((tagId == HtmlTagId.A || tagId == HtmlTagId.Area) && attribute.Id == HtmlAttributeId.Href);
 }
예제 #17
0
 protected static bool IsTargetTagInAnchor(HtmlTagId tagId, HtmlTagContextAttribute attr)
 {
     return((tagId == HtmlTagId.A || tagId == HtmlTagId.Area) && attr.Id == HtmlAttributeId.Target);
 }
예제 #18
0
 protected static bool IsSanitizingAttribute(HtmlTagContextAttribute attribute)
 {
     return(attribute.Id == HtmlAttributeId.Border || attribute.Id == HtmlAttributeId.Width || attribute.Id == HtmlAttributeId.Height);
 }
예제 #19
0
 protected static bool IsImageTag(HtmlTagId tagId, HtmlTagContextAttribute attribute)
 {
     return(tagId == HtmlTagId.Img && (attribute.Id == HtmlAttributeId.Src || attribute.Id == HtmlAttributeId.DynSrc || attribute.Id == HtmlAttributeId.LowSrc));
 }
예제 #20
0
 protected static bool IsBackgroundAttribute(HtmlTagContextAttribute attribute)
 {
     return(attribute.Id == HtmlAttributeId.Background);
 }
 protected virtual void ProcessUseMapAttribute(HtmlTagContextAttribute filterAttribute, HtmlTagContext context, HtmlWriter writer)
 {
 }