public static void DeleteLevelOneAttachments(Item newItem, UserContext userContext) { if (newItem == null) { throw new ArgumentNullException("newItem"); } List <AttachmentId> list = new List <AttachmentId>(); foreach (AttachmentHandle handle in newItem.AttachmentCollection) { using (Attachment attachment = newItem.AttachmentCollection.Open(handle)) { AttachmentPolicy.Level attachmentLevel = AttachmentLevelLookup.GetAttachmentLevel(attachment, userContext); if (attachmentLevel == AttachmentPolicy.Level.Block) { list.Add(attachment.Id); } } } if (list.Count != 0) { foreach (AttachmentId attachmentId in list) { newItem.AttachmentCollection.Remove(attachmentId); } ConflictResolutionResult conflictResolutionResult = newItem.Save(SaveMode.ResolveConflicts); if (conflictResolutionResult.SaveStatus == SaveResult.IrresolvableConflict) { newItem.Dispose(); newItem = null; throw new OwaSaveConflictException(LocalizedStrings.GetNonEncoded(-482397486), conflictResolutionResult); } } newItem.Load(); }
public static AttachmentPolicy.Level GetAttachmentLevel(AttachmentInfo attachmentInfo, UserContext userContext) { if (attachmentInfo == null) { throw new ArgumentNullException("attachmentInfo"); } return(AttachmentLevelLookup.GetAttachmentLevel(attachmentInfo.AttachmentType, attachmentInfo.FileExtension, attachmentInfo.ContentType, userContext)); }
public static AttachmentPolicy.Level GetAttachmentLevel(Attachment attachment, UserContext userContext) { if (attachment == null) { throw new ArgumentNullException("attachment"); } return(AttachmentLevelLookup.GetAttachmentLevel(attachment.AttachmentType, attachment.FileExtension, attachment.ContentType ?? attachment.CalculatedContentType, userContext)); }
private static AttachmentPolicy.Level GetAttachmentLevel(AttachmentType attachmentType, string fileExtension, string mimeType, UserContext userContext) { if (attachmentType == AttachmentType.Ole || attachmentType == AttachmentType.EmbeddedMessage) { return(AttachmentPolicy.Level.Allow); } return(AttachmentLevelLookup.GetLevelForAttachment(fileExtension, mimeType, userContext)); }
// Token: 0x0600071C RID: 1820 RVA: 0x00037B9C File Offset: 0x00035D9C private void ProcessAttachment(Attachment attachment, HttpContext httpContext, BlockStatus blockStatus) { if (attachment == null) { throw new ArgumentNullException("attachment"); } OwaContext owaContext = OwaContext.Get(httpContext); UserContext userContext = owaContext.UserContext; Stream stream = null; try { StreamAttachmentBase streamAttachment = AttachmentUtility.GetStreamAttachment(attachment); if (streamAttachment == null) { ExTraceGlobals.AttachmentHandlingTracer.TraceError((long)this.GetHashCode(), "AttachmentHandler.ProcessAttachment: attachment is not derived from AttachmentStream"); } else { AttachmentPolicy.Level attachmentLevel = AttachmentLevelLookup.GetAttachmentLevel(streamAttachment, userContext); if (attachmentLevel == AttachmentPolicy.Level.Block) { Utilities.TransferToErrorPage(owaContext, LocalizedStrings.GetNonEncoded(-2000404449), LocalizedStrings.GetNonEncoded(-615885395)); } else { string fileName = AttachmentUtility.CalculateAttachmentName(streamAttachment.DisplayName, streamAttachment.FileName); string text = streamAttachment.FileExtension; if (text == null) { text = string.Empty; } string empty = string.Empty; bool contentType = this.GetContentType(httpContext, streamAttachment, attachmentLevel, out empty); bool isInline = this.GetIsInline(streamAttachment, attachmentLevel); stream = AttachmentUtility.GetStream(streamAttachment); if (stream == null) { ExTraceGlobals.AttachmentHandlingTracer.TraceError((long)this.GetHashCode(), "AttachmentHandler.ProcessAttachment: Image conversion of OLE attachment failure"); } else { AttachmentHandler.SendDocumentContentToHttpStream(httpContext, stream, fileName, text, empty, isInline, streamAttachment.TextCharset, blockStatus, attachmentLevel, contentType); } } } } finally { if (stream != null) { stream.Dispose(); } } }
protected AttachmentPolicy.Level GetAttachmentLevel(AttachmentLink attachmentLink) { if (this.isJunkOrPhishing) { return(AttachmentPolicy.Level.Block); } if (attachmentLink.AttachmentType == AttachmentType.EmbeddedMessage) { return(AttachmentPolicy.Level.Block); } return(AttachmentLevelLookup.GetAttachmentLevel(attachmentLink, this.owaContext.UserContext)); }
protected void RenderMessage(TextWriter output) { if (output == null) { throw new ArgumentNullException("output"); } AttachmentPolicy.Level levelForAttachment = AttachmentLevelLookup.GetLevelForAttachment(this.utilities.FileExtension, this.utilities.MimeType, base.UserContext); if (AttachmentPolicy.Level.Block == levelForAttachment) { if (base.UserContext.IsBasicExperience) { output.Write("<table class=tbWIB><tr><td class=\""); output.Write(Utilities.GetTDClassForWebReadyViewHead(base.UserContext.IsBasicExperience)); output.Write("\"><img class=\"iei errInfo\" src=\""); base.OwaContext.UserContext.RenderThemeFileUrl(output, ThemeFileId.Exclaim); output.Write("\" alt=\"\"><span class=\"errInfo\">"); } else { output.Write("<table class=tbWIB><tr><td>"); base.OwaContext.UserContext.RenderThemeImage(output, ThemeFileId.Exclaim, "iei errInfo", new object[0]); output.Write("<span class=\"errInfo\">"); } output.Write(LocalizedStrings.GetHtmlEncoded(437967712)); output.Write("</span></td></tr></table>"); return; } if (AttachmentPolicy.Level.ForceSave == levelForAttachment) { output.Write("<table class=tbNIB><tr><td class=\"msg "); output.Write(Utilities.GetTDClassForWebReadyViewHead(base.UserContext.IsBasicExperience)); output.Write("\">"); this.RenderHtmlEncodedSaveAttachmentToDiskMessage(); output.Write("</td></tr></table>"); return; } if (AttachmentPolicy.Level.Allow == levelForAttachment) { output.Write("<table class=tbNIB><tr><td class=\"msg "); output.Write(Utilities.GetTDClassForWebReadyViewHead(base.UserContext.IsBasicExperience)); output.Write("\">"); output.Write(base.UserContext.IsBasicExperience ? LocalizedStrings.GetHtmlEncoded(94137446) : LocalizedStrings.GetHtmlEncoded(2080319064)); output.Write("</td></tr></table>"); } }
public void RenderOpenLink(TextWriter output) { if (output == null) { throw new ArgumentNullException("output"); } AttachmentPolicy.Level levelForAttachment = AttachmentLevelLookup.GetLevelForAttachment(this.fileExtension, this.mimeType, this.owaContext.UserContext); output.Write("<span id=\"spnLnk\" tabindex=\"-1\">"); SmallIconManager.RenderFileIcon(output, this.owaContext.UserContext, this.fileExtension, "tbLh", new string[0]); output.Write("<span class=\"tbLh\">"); if (levelForAttachment == AttachmentPolicy.Level.ForceSave || levelForAttachment == AttachmentPolicy.Level.Allow) { output.Write("<a id=\"lnk\" href=\""); output.Write(this.openLink); output.Write("\" target=_blank onclick=\""); output.Write("return onClkAtmt("); output.Write((int)levelForAttachment); output.Write(")\" title=\""); Utilities.HtmlEncode(this.fileName, output); output.Write("\">"); Utilities.HtmlEncode(AttachmentUtility.TrimAttachmentDisplayName(this.fileName, null, false), output); output.Write("</a>"); } else { Utilities.HtmlEncode(AttachmentUtility.TrimAttachmentDisplayName(this.fileName, null, false), output); } if (this.fileSize > 0L) { output.Write(this.owaContext.UserContext.DirectionMark); output.Write(" "); output.Write(LocalizedStrings.GetHtmlEncoded(6409762)); Utilities.RenderSizeWithUnits(output, this.fileSize, true); output.Write(this.owaContext.UserContext.DirectionMark); output.Write(LocalizedStrings.GetHtmlEncoded(-1023695022)); } output.Write("</span></span>"); }