예제 #1
0
        public void AddAttachmentToZip(AttachmentWellInfo attachmentWellInfo, UserContext userContext, HttpContext httpContext)
        {
            if (attachmentWellInfo == null)
            {
                throw new ArgumentNullException("attachmentWellInfo");
            }
            if (userContext == null)
            {
                throw new ArgumentNullException("userContext");
            }
            if (httpContext == null)
            {
                throw new ArgumentNullException("httpContext");
            }
            if (attachmentWellInfo.AttachmentType == AttachmentType.EmbeddedMessage)
            {
                this.hasEmbeddedItem = true;
            }
            bool   doNeedToFilterHtml = AttachmentUtility.DoNeedToFilterHtml(attachmentWellInfo.MimeType, attachmentWellInfo.FileExtension, attachmentWellInfo.AttachmentLevel, userContext);
            bool   isNotHtmlandNotXml = !AttachmentUtility.GetIsHtmlOrXml(attachmentWellInfo.MimeType, attachmentWellInfo.FileExtension);
            bool   doNotSniff         = AttachmentUtility.GetDoNotSniff(attachmentWellInfo.AttachmentLevel, userContext);
            string text = attachmentWellInfo.AttachmentName;

            if (attachmentWellInfo.AttachmentType == AttachmentType.EmbeddedMessage)
            {
                text += attachmentWellInfo.FileExtension;
            }
            string text2 = this.ConditionZipEntryFileName(text);

            attachmentWellInfo.FileName = text2;
            ZipEntryAttachment value = new ZipEntryAttachment(text2, attachmentWellInfo, doNeedToFilterHtml, doNotSniff, isNotHtmlandNotXml);

            this.files.Add(text2, value);
        }
        // Token: 0x06000717 RID: 1815 RVA: 0x0003786C File Offset: 0x00035A6C
        private static int SendDocumentContentToHttpStream(HttpContext httpContext, Stream stream, string fileName, string fileExtension, string contentType, bool isInline, Charset charset, BlockStatus blockStatus, AttachmentPolicy.Level level, bool doNeedToFilterHtml)
        {
            if (AttachmentUtility.IsMhtmlAttachment(contentType, fileExtension))
            {
                ExTraceGlobals.AttachmentHandlingTracer.TraceDebug <string>(0L, "AttachmentHandler.SendDocumentContentToHttpStream: Explicitly blocking MHTML attachment {0}", fileName);
                return(0);
            }
            AttachmentHandler.SetAttachmentResponseHeaders(httpContext, fileName, contentType, isInline, level);
            uint result;

            if (doNeedToFilterHtml)
            {
                result = AttachmentUtility.WriteFilteredResponse(httpContext, stream, charset, blockStatus);
            }
            else
            {
                bool isNotHtmlandNotXml = !AttachmentUtility.GetIsHtmlOrXml(contentType, fileExtension);
                bool doNotSniff         = AttachmentUtility.GetDoNotSniff(level, OwaContext.Get(httpContext).UserContext);
                result = AttachmentUtility.WriteUnfilteredResponse(httpContext, stream, fileName, isNotHtmlandNotXml, doNotSniff);
            }
            return((int)result);
        }