Пример #1
0
        private static bool CheckShouldRemoveContents(Stream stream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }
            if (!stream.CanSeek)
            {
                throw new ArgumentException("Stream is required to support Seek operations, and does not");
            }
            byte[] array       = new byte[512];
            int    bytesToRead = stream.Read(array, 0, 512);
            bool   result      = ZipEntryAttachment.CheckShouldRemoveContents(array, bytesToRead);

            stream.Seek(0L, SeekOrigin.Begin);
            return(result);
        }
Пример #2
0
 private Stream GetUnfilteredStream(Stream stream)
 {
     if (!stream.CanSeek)
     {
         throw new ArgumentException("stream", "Stream is required to support Seek operations, and does not");
     }
     if (!this.doNotSniff && this.isNotHtmlandNotXml && ZipEntryAttachment.CheckShouldRemoveContents(stream))
     {
         if (ExTraceGlobals.AttachmentHandlingTracer.IsTraceEnabled(TraceType.DebugTrace))
         {
             ExTraceGlobals.AttachmentHandlingTracer.TraceDebug <string, string>((long)this.GetHashCode(), "ZipEntryAttachment.GetUnfilteredStream: Return contents removed for attachment {0}: mailbox {1}", this.fileName, AttachmentUtilities.TryGetMailboxIdentityName());
         }
         return(ZipEntryAttachment.GetContentsReplacementStream(-1868113279));
     }
     if (ExTraceGlobals.AttachmentHandlingTracer.IsTraceEnabled(TraceType.DebugTrace))
     {
         ExTraceGlobals.AttachmentHandlingTracer.TraceDebug <string, string>((long)this.GetHashCode(), "ZipEntryAttachment.GetUnfilteredStream: Return original contents for attachment {0}: mailbox {1}", this.fileName, AttachmentUtilities.TryGetMailboxIdentityName());
     }
     return(stream);
 }