Exemplo n.º 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: 0x06000716 RID: 1814 RVA: 0x000377E8 File Offset: 0x000359E8
        internal static int SendDocumentContentToHttpStream(HttpContext httpContext, Stream stream, string fileName, string fileExtension, string contentType)
        {
            if (httpContext == null)
            {
                throw new ArgumentNullException("httpContext");
            }
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }
            if (string.IsNullOrEmpty(fileName))
            {
                fileName = LocalizedStrings.GetNonEncoded(1797976510);
            }
            if (fileExtension == null)
            {
                fileExtension = string.Empty;
            }
            if (contentType == null)
            {
                contentType = string.Empty;
            }
            bool flag = AttachmentUtility.DoNeedToFilterHtml(contentType, fileExtension, AttachmentPolicy.Level.Unknown, OwaContext.Get(httpContext).UserContext);

            if (flag)
            {
                AttachmentUtility.UpdateContentTypeForNeedToFilter(out contentType, null);
            }
            return(AttachmentHandler.SendDocumentContentToHttpStream(httpContext, stream, fileName, fileExtension, contentType, false, null, BlockStatus.DontKnow, AttachmentPolicy.Level.Unknown, flag));
        }
        // Token: 0x0600071F RID: 1823 RVA: 0x00037D98 File Offset: 0x00035F98
        private bool GetContentType(HttpContext httpContext, StreamAttachmentBase streamAttachment, AttachmentPolicy.Level level, out string contentType)
        {
            contentType = AttachmentUtility.CalculateContentType(streamAttachment);
            bool flag = AttachmentUtility.DoNeedToFilterHtml(contentType, streamAttachment.FileExtension, level, OwaContext.Get(httpContext).UserContext);

            if (string.IsNullOrEmpty(contentType) && this.IsVoiceMailAttachment(httpContext))
            {
                contentType = "audio/x-ms-wma";
            }
            else if (flag)
            {
                AttachmentUtility.UpdateContentTypeForNeedToFilter(out contentType, streamAttachment.TextCharset);
            }
            return(flag);
        }