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(); }
private string GetInlineReferenceUrl(AttachmentPolicy.Level level, AttachmentLink imageAttachmentLink, HtmlWriter writer) { imageAttachmentLink.MarkInline(true); if (AttachmentPolicy.Level.Allow == level) { StringBuilder stringBuilder = new StringBuilder(); if (this.isEmbeddedItem) { stringBuilder.Append(this.embeddedItemUrl); } else { stringBuilder.Append(OwaSafeHtmlCallbackBase.AttachmentBaseUrl); bool flag = this.owaStoreObjectIdType == OwaStoreObjectIdType.OtherUserMailboxObject || this.owaStoreObjectIdType == OwaStoreObjectIdType.ArchiveMailboxObject; OwaStoreObjectId owaStoreObjectId = OwaStoreObjectId.CreateFromItemId(this.itemId, flag ? null : this.parentId, this.owaStoreObjectIdType, this.legacyDN); stringBuilder.Append(Utilities.UrlEncode(owaStoreObjectId.ToString())); stringBuilder.Append("&attcnt=1&attid0="); } stringBuilder.Append(Utilities.UrlEncode(imageAttachmentLink.AttachmentId.ToBase64String())); if (!this.isEmbeddedItem && !string.IsNullOrEmpty(imageAttachmentLink.ContentId)) { stringBuilder.Append("&attcid0="); stringBuilder.Append(Utilities.UrlEncode(imageAttachmentLink.ContentId)); } return(stringBuilder.ToString()); } this.hasBlockedImagesInCurrentPass = true; this.hasBlockedInlineAttachments = true; return(OwaSafeHtmlOutboundCallbacks.BlockedUrlPageValue); }
internal static PolicyConfiguration GetPolicyConfigurationFromAD(IConfigurationSession session, ADObjectId owaMailboxPolicyId) { OwaMailboxPolicy[] array = session.Find <OwaMailboxPolicy>(owaMailboxPolicyId, QueryScope.Base, null, null, 1); OwaMailboxPolicy owaMailboxPolicy = null; if (array != null && array.Length == 1) { owaMailboxPolicy = array[0]; } if (owaMailboxPolicy == null) { ExTraceGlobals.PolicyConfigurationTracer.TraceError <ADObjectId>(0L, LocalizedStrings.GetNonEncoded(246332502), owaMailboxPolicyId); return(null); } PolicyConfiguration policyConfiguration = new PolicyConfiguration(); policyConfiguration.PhoneticSupportEnabled = owaMailboxPolicy.PhoneticSupportEnabled; AttachmentPolicy.Level treatUnknownTypeAs = ConfigurationBase.AttachmentActionToLevel(new AttachmentBlockingActions?(owaMailboxPolicy.ActionForUnknownFileAndMIMETypes)); AttachmentPolicy attachmentPolicy = new AttachmentPolicy(owaMailboxPolicy.BlockedFileTypes.ToArray(), owaMailboxPolicy.BlockedMimeTypes.ToArray(), owaMailboxPolicy.ForceSaveFileTypes.ToArray(), owaMailboxPolicy.ForceSaveMimeTypes.ToArray(), owaMailboxPolicy.AllowedFileTypes.ToArray(), owaMailboxPolicy.AllowedMimeTypes.ToArray(), treatUnknownTypeAs, owaMailboxPolicy.DirectFileAccessOnPublicComputersEnabled, owaMailboxPolicy.DirectFileAccessOnPrivateComputersEnabled, owaMailboxPolicy.ForceWebReadyDocumentViewingFirstOnPublicComputers, owaMailboxPolicy.ForceWebReadyDocumentViewingFirstOnPrivateComputers, owaMailboxPolicy.WebReadyDocumentViewingOnPublicComputersEnabled, owaMailboxPolicy.WebReadyDocumentViewingOnPrivateComputersEnabled, owaMailboxPolicy.WebReadyFileTypes.ToArray(), owaMailboxPolicy.WebReadyMimeTypes.ToArray(), owaMailboxPolicy.WebReadyDocumentViewingSupportedFileTypes.ToArray(), owaMailboxPolicy.WebReadyDocumentViewingSupportedMimeTypes.ToArray(), owaMailboxPolicy.WebReadyDocumentViewingForAllSupportedTypes); policyConfiguration.AttachmentPolicy = attachmentPolicy; policyConfiguration.DefaultClientLanguage = owaMailboxPolicy.DefaultClientLanguage; policyConfiguration.LogonAndErrorLanguage = owaMailboxPolicy.LogonAndErrorLanguage; policyConfiguration.DefaultTheme = owaMailboxPolicy.DefaultTheme; policyConfiguration.SetPhotoURL = owaMailboxPolicy.SetPhotoURL; int segmentationBits = (int)owaMailboxPolicy[OwaMailboxPolicySchema.ADMailboxFolderSet]; int segmentationBits2 = (int)owaMailboxPolicy[OwaMailboxPolicySchema.ADMailboxFolderSet2]; policyConfiguration.SegmentationFlags = Utilities.SetSegmentationFlags(segmentationBits, segmentationBits2); policyConfiguration.OutboundCharset = owaMailboxPolicy.OutboundCharset; policyConfiguration.UseGB18030 = owaMailboxPolicy.UseGB18030; policyConfiguration.UseISO885915 = owaMailboxPolicy.UseISO885915; policyConfiguration.InstantMessagingType = ((owaMailboxPolicy.InstantMessagingType != null) ? owaMailboxPolicy.InstantMessagingType.Value : InstantMessagingTypeOptions.None); return(policyConfiguration); }
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)); }
// Token: 0x06001394 RID: 5012 RVA: 0x00070A58 File Offset: 0x0006EC58 private static void LoadDictionary(out SortedDictionary <string, AttachmentPolicy.Level> dictionary, string[] block, string[] forceSave, string[] allow) { string[][] array = new string[3][]; AttachmentPolicy.Level[] array2 = new AttachmentPolicy.Level[3]; array[1] = block; array[2] = forceSave; array[0] = allow; array2[1] = AttachmentPolicy.Level.Block; array2[2] = AttachmentPolicy.Level.ForceSave; array2[0] = AttachmentPolicy.Level.Allow; for (int i = 0; i < array.Length; i++) { if (array[i] == null) { array[i] = new string[0]; } } dictionary = new SortedDictionary <string, AttachmentPolicy.Level>(StringComparer.OrdinalIgnoreCase); for (int j = 0; j < 2; j++) { for (int k = 0; k < array[j].Length; k++) { if (!dictionary.ContainsKey(array[j][k])) { dictionary.Add(array[j][k], array2[j]); } } } }
private static SortedDictionary <string, AttachmentPolicy.Level> LoadDictionary(string[] block, string[] forceSave, string[] allow) { string[][] array = new string[3][]; AttachmentPolicy.Level[] array2 = new AttachmentPolicy.Level[3]; array[1] = block; array[2] = forceSave; array[0] = allow; array2[1] = AttachmentPolicy.Level.Block; array2[2] = AttachmentPolicy.Level.ForceSave; array2[0] = AttachmentPolicy.Level.Allow; for (int i = 0; i < array.Length; i++) { if (array[i] == null) { array[i] = new string[0]; } } SortedDictionary <string, AttachmentPolicy.Level> sortedDictionary = new SortedDictionary <string, AttachmentPolicy.Level>(StringComparer.OrdinalIgnoreCase); for (int j = 0; j <= 2; j++) { for (int k = 0; k < array[j].Length; k++) { string key = array[j][k]; if (!sortedDictionary.ContainsKey(key)) { sortedDictionary.Add(key, array2[j]); } } } return(sortedDictionary); }
// 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(); } } }
public AttachmentPolicy.Level GetLevel(string attachmentType, AttachmentPolicy.TypeSignifier typeSignifier) { AttachmentPolicy.Level result = AttachmentPolicy.Level.Unknown; switch (typeSignifier) { case AttachmentPolicy.TypeSignifier.File: result = AttachmentPolicy.FindLevel(this.fileTypeLevels, attachmentType); break; case AttachmentPolicy.TypeSignifier.Mime: result = AttachmentPolicy.FindLevel(this.mimeTypeLevels, attachmentType); break; } return(result); }
// Token: 0x06002C61 RID: 11361 RVA: 0x000F7264 File Offset: 0x000F5464 private Stream GetContactPictureStream(Item item, string attId, out string contentType) { contentType = string.Empty; if (item == null) { return(new MemoryStream()); } if (string.IsNullOrEmpty(attId)) { attId = RenderingUtilities.GetContactPictureAttachmentId(item); } if (string.IsNullOrEmpty(attId)) { return(new MemoryStream()); } AttachmentId id = item.CreateAttachmentId(attId); AttachmentCollection attachmentCollection = Utilities.GetAttachmentCollection(item, true, base.UserContext); Stream result; using (StreamAttachment streamAttachment = attachmentCollection.Open(id) as StreamAttachment) { if (streamAttachment == null) { throw new OwaInvalidRequestException("Attachment is not a stream attachment"); } AttachmentPolicy.Level attachmentLevel = AttachmentLevelLookup.GetAttachmentLevel(streamAttachment, base.UserContext); if (attachmentLevel == AttachmentPolicy.Level.Block) { result = new MemoryStream(); } else { contentType = AttachmentEventHandler.GetContentType(streamAttachment.FileName); if (contentType.Length == 0) { ExTraceGlobals.ContactsTracer.TraceDebug <string>((long)this.GetHashCode(), "Cannot determine image type for file: {0}", streamAttachment.FileName); result = new MemoryStream(); } else { result = streamAttachment.GetContentStream(); } } } return(result); }
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>"); } }
internal CalendarVDirConfiguration() { base.PhoneticSupportEnabled = true; this.formsAuthenticationEnabled = 0; AttachmentPolicy.Level treatUnknownTypeAs = AttachmentPolicy.Level.Block; AttachmentPolicy attachmentPolicy = new AttachmentPolicy(new string[0], new string[0], new string[0], new string[0], new string[0], new string[0], treatUnknownTypeAs, false, false, false, false, false, false, new string[0], new string[0], new string[0], new string[0], false); base.AttachmentPolicy = attachmentPolicy; base.DefaultClientLanguage = Globals.ServerCulture.LCID; this.filterWebBeaconsAndHtmlForms = WebBeaconFilterLevels.ForceFilter; base.LogonAndErrorLanguage = Globals.ServerCulture.LCID; this.logonFormat = LogonFormats.FullDomain; this.defaultDomain = string.Empty; this.notificationInterval = -1; this.sessionTimeout = -1; this.redirectToOptimalOWAServer = true; base.DefaultTheme = string.Empty; this.clientAuthCleanupLevel = ClientAuthCleanupLevels.High; this.isSMimeEnabledOnCurrentServerr = false; this.documentAccessAllowedServers = new string[0]; this.documentAccessBlockedServers = new string[0]; this.documentAccessInternalDomainSuffixList = new string[0]; RemoteDocumentsActions?remoteDocumentsActions = new RemoteDocumentsActions?(RemoteDocumentsActions.Block); if (remoteDocumentsActions != null) { if (remoteDocumentsActions == RemoteDocumentsActions.Allow) { this.remoteDocumentsActionForUnknownServers = RemoteDocumentsActions.Allow; } else { this.remoteDocumentsActionForUnknownServers = RemoteDocumentsActions.Block; } } base.InternalAuthenticationMethod = AuthenticationMethod.None; base.ExternalAuthenticationMethod = AuthenticationMethod.None; base.Exchange2003Url = null; base.LegacyRedirectType = LegacyRedirectTypeOptions.Manual; base.SegmentationFlags = 536871426UL; base.InstantMessagingType = InstantMessagingTypeOptions.None; this.defaultAcceptedDomain = null; this.publicFoldersEnabledOnThisVdir = false; }
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); }
public static AttachmentPolicy.Level GetLevelForAttachment(string fileExtension, string mimeType, UserContext userContext) { if (fileExtension == null) { throw new ArgumentNullException("fileExtension"); } AttachmentPolicy attachmentPolicy; if (userContext != null) { attachmentPolicy = userContext.AttachmentPolicy; } else { attachmentPolicy = OwaConfigurationManager.Configuration.AttachmentPolicy; } if (mimeType == null || !attachmentPolicy.DirectFileAccessEnabled) { return(AttachmentPolicy.Level.Block); } AttachmentPolicy.Level level = attachmentPolicy.GetLevel(fileExtension, AttachmentPolicy.TypeSignifier.File); if (level == AttachmentPolicy.Level.Allow) { return(level); } AttachmentPolicy.Level level2 = attachmentPolicy.GetLevel(mimeType, AttachmentPolicy.TypeSignifier.Mime); if (level2 == AttachmentPolicy.Level.Allow) { return(level2); } if (level == AttachmentPolicy.Level.Unknown && level2 == AttachmentPolicy.Level.Unknown) { return(attachmentPolicy.TreatUnknownTypeAs); } if (level < level2) { return(level); } return(level2); }
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>"); }
public void GetDocument() { bool flag = false; ExTraceGlobals.MailCallTracer.TraceDebug((long)this.GetHashCode(), "DocumentEventHandler.GetDocument"); base.ShowErrorInPage = true; base.DontWriteHeaders = true; HttpContext httpContext = base.OwaContext.HttpContext; if (!DocumentLibraryUtilities.IsDocumentsAccessEnabled(base.UserContext)) { throw new OwaSegmentationException("Access to this document library is disabled"); } string text = (string)base.GetParameter("id"); string s = (string)base.GetParameter("URL"); DocumentLibraryObjectId documentLibraryObjectId = DocumentLibraryUtilities.CreateDocumentLibraryObjectId(base.OwaContext); if (documentLibraryObjectId == null) { return; } try { this.DataBind(documentLibraryObjectId); } finally { if (this.stream == null) { this.Dispose(); } } if (this.stream == null) { return; } UserContext userContext = base.OwaContext.UserContext; AttachmentPolicy.Level levelForAttachment = AttachmentLevelLookup.GetLevelForAttachment(Path.GetExtension(this.fileName), this.contentType, userContext); if (base.IsParameterSet("allowLevel2")) { flag = true; } if (levelForAttachment == AttachmentPolicy.Level.Block) { string errorDescription = string.Format(CultureInfo.InvariantCulture, LocalizedStrings.GetNonEncoded(1280363351), new object[] { this.fileName }); Utilities.TransferToErrorPage(base.OwaContext, errorDescription, null, ThemeFileId.ButtonDialogInfo, true); return; } if (levelForAttachment == AttachmentPolicy.Level.ForceSave && !flag) { string queryStringParameter = Utilities.GetQueryStringParameter(httpContext.Request, "ns"); string text2 = string.Concat(new string[] { "<br> <a onclick=\"return false;\" href=\"ev.owa?ns=", queryStringParameter, "&ev=GetDoc&allowLevel2=1&URL=", Utilities.UrlEncode(s), "&id=", Utilities.UrlEncode(documentLibraryObjectId.ToBase64String()), Utilities.GetCanaryRequestParameter(), "\">", Utilities.HtmlEncode(this.fileName), "</a>" }); string errorDetailedDescription = string.Format(CultureInfo.InvariantCulture, LocalizedStrings.GetHtmlEncoded(-625229753), new object[] { text2 }); Utilities.TransferToErrorPage(base.OwaContext, LocalizedStrings.GetHtmlEncoded(-226672911), errorDetailedDescription, ThemeFileId.ButtonDialogInfo, true, true); return; } int num = AttachmentHandler.SendDocumentContentToHttpStream(httpContext, this.stream, this.fileName, DocumentEventHandler.CalculateFileExtension(this.fileName), this.contentType); if (this.contentType != null && this.contentType.Equals("application/x-zip-compressed", StringComparison.OrdinalIgnoreCase)) { Utilities.DisableContentEncodingForThisResponse(base.OwaContext.HttpContext.Response); } if (Globals.ArePerfCountersEnabled) { if ((documentLibraryObjectId.UriFlags & UriFlags.Sharepoint) != (UriFlags)0) { OwaSingleCounters.WssBytes.IncrementBy((long)num); OwaSingleCounters.WssRequests.Increment(); return; } if ((documentLibraryObjectId.UriFlags & UriFlags.Unc) != (UriFlags)0) { OwaSingleCounters.UncBytes.IncrementBy((long)num); OwaSingleCounters.UncRequests.Increment(); } } }
// Token: 0x0600138D RID: 5005 RVA: 0x00070996 File Offset: 0x0006EB96 internal AttachmentPolicy(string[] blockFileTypes, string[] blockMimeTypes, string[] forceSaveFileTypes, string[] forceSaveMimeTypes, string[] allowFileTypes, string[] allowMimeTypes, bool alwaysBlock, bool blockOnPublicComputers, AttachmentPolicy.Level treatUnknownTypeAs) { this.alwaysBlock = alwaysBlock; this.blockOnPublicComputers = blockOnPublicComputers; this.treatUnknownTypeAs = treatUnknownTypeAs; AttachmentPolicy.LoadDictionary(out this.fileTypeLevels, blockFileTypes, forceSaveFileTypes, allowFileTypes); AttachmentPolicy.LoadDictionary(out this.mimeTypeLevels, blockMimeTypes, forceSaveMimeTypes, allowMimeTypes); }
// 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); }
// Token: 0x06000721 RID: 1825 RVA: 0x00037E14 File Offset: 0x00036014 private bool GetIsInline(StreamAttachmentBase streamAttachment, AttachmentPolicy.Level level) { OleAttachment oleAttachment = streamAttachment as OleAttachment; return(level == AttachmentPolicy.Level.Allow && (streamAttachment.IsInline || null != oleAttachment)); }
// Token: 0x06000818 RID: 2072 RVA: 0x0003BA7C File Offset: 0x00039C7C internal Configuration(IConfigurationSession session, string virtualDirectory, string webSiteName, ADObjectId vDirADObjectId, bool isPhoneticSupportEnabled) { base.PhoneticSupportEnabled = isPhoneticSupportEnabled; if (Globals.IsPreCheckinApp) { this.ExpirationTime = DateTime.UtcNow + Configuration.expirationPeriod; this.LoadPreCheckInVdirConfiguration(); return; } ADOwaVirtualDirectory adowaVirtualDirectory = session.Read <ADOwaVirtualDirectory>(vDirADObjectId); if (adowaVirtualDirectory == null) { string message = string.Format(LocalizedStrings.GetNonEncoded(-1166886287), virtualDirectory, webSiteName); throw new OwaInvalidConfigurationException(message); } this.formsAuthenticationEnabled = (adowaVirtualDirectory.InternalAuthenticationMethods.Contains(AuthenticationMethod.Fba) ? 1 : 0); AttachmentPolicy.Level treatUnknownTypeAs = ConfigurationBase.AttachmentActionToLevel(adowaVirtualDirectory.ActionForUnknownFileAndMIMETypes); AttachmentPolicy attachmentPolicy = new AttachmentPolicy(adowaVirtualDirectory.BlockedFileTypes.ToArray(), adowaVirtualDirectory.BlockedMimeTypes.ToArray(), adowaVirtualDirectory.ForceSaveFileTypes.ToArray(), adowaVirtualDirectory.ForceSaveMimeTypes.ToArray(), adowaVirtualDirectory.AllowedFileTypes.ToArray(), adowaVirtualDirectory.AllowedMimeTypes.ToArray(), treatUnknownTypeAs, adowaVirtualDirectory.DirectFileAccessOnPublicComputersEnabled.Value, adowaVirtualDirectory.DirectFileAccessOnPrivateComputersEnabled.Value, adowaVirtualDirectory.ForceWebReadyDocumentViewingFirstOnPublicComputers.Value, adowaVirtualDirectory.ForceWebReadyDocumentViewingFirstOnPrivateComputers.Value, adowaVirtualDirectory.WebReadyDocumentViewingOnPublicComputersEnabled.Value, adowaVirtualDirectory.WebReadyDocumentViewingOnPrivateComputersEnabled.Value, adowaVirtualDirectory.WebReadyFileTypes.ToArray(), adowaVirtualDirectory.WebReadyMimeTypes.ToArray(), adowaVirtualDirectory.WebReadyDocumentViewingSupportedFileTypes.ToArray(), adowaVirtualDirectory.WebReadyDocumentViewingSupportedMimeTypes.ToArray(), adowaVirtualDirectory.WebReadyDocumentViewingForAllSupportedTypes.Value); base.AttachmentPolicy = attachmentPolicy; base.DefaultClientLanguage = adowaVirtualDirectory.DefaultClientLanguage.Value; this.filterWebBeaconsAndHtmlForms = adowaVirtualDirectory.FilterWebBeaconsAndHtmlForms.Value; base.LogonAndErrorLanguage = adowaVirtualDirectory.LogonAndErrorLanguage; this.logonFormat = adowaVirtualDirectory.LogonFormat; this.defaultDomain = adowaVirtualDirectory.DefaultDomain; this.notificationInterval = (adowaVirtualDirectory.NotificationInterval ?? 120); this.sessionTimeout = (adowaVirtualDirectory.UserContextTimeout ?? 60); this.redirectToOptimalOWAServer = (adowaVirtualDirectory.RedirectToOptimalOWAServer == true); base.DefaultTheme = adowaVirtualDirectory.DefaultTheme; base.SetPhotoURL = adowaVirtualDirectory.SetPhotoURL; this.clientAuthCleanupLevel = adowaVirtualDirectory.ClientAuthCleanupLevel; this.imCertificateThumbprint = adowaVirtualDirectory.InstantMessagingCertificateThumbprint; this.imServerName = adowaVirtualDirectory.InstantMessagingServerName; this.isSMimeEnabledOnCurrentServerr = (adowaVirtualDirectory.SMimeEnabled ?? false); this.documentAccessAllowedServers = adowaVirtualDirectory.RemoteDocumentsAllowedServers.ToArray(); this.documentAccessBlockedServers = adowaVirtualDirectory.RemoteDocumentsBlockedServers.ToArray(); this.documentAccessInternalDomainSuffixList = adowaVirtualDirectory.RemoteDocumentsInternalDomainSuffixList.ToArray(); RemoteDocumentsActions?remoteDocumentsActions = adowaVirtualDirectory.RemoteDocumentsActionForUnknownServers; if (remoteDocumentsActions != null) { if (remoteDocumentsActions == RemoteDocumentsActions.Allow) { this.remoteDocumentsActionForUnknownServers = RemoteDocumentsActions.Allow; } else { this.remoteDocumentsActionForUnknownServers = RemoteDocumentsActions.Block; } } base.InternalAuthenticationMethod = ConfigurationBase.GetAuthenticationMethod(adowaVirtualDirectory[ADVirtualDirectorySchema.InternalAuthenticationMethodFlags]); base.ExternalAuthenticationMethod = ConfigurationBase.GetAuthenticationMethod(adowaVirtualDirectory[ADVirtualDirectorySchema.ExternalAuthenticationMethodFlags]); base.Exchange2003Url = adowaVirtualDirectory.Exchange2003Url; base.LegacyRedirectType = LegacyRedirectTypeOptions.Silent; int segmentationBits = (int)adowaVirtualDirectory[ADOwaVirtualDirectorySchema.ADMailboxFolderSet]; int segmentationBits2 = (int)adowaVirtualDirectory[ADOwaVirtualDirectorySchema.ADMailboxFolderSet2]; base.SegmentationFlags = Utilities.SetSegmentationFlags(segmentationBits, segmentationBits2); if (adowaVirtualDirectory.OutboundCharset != null) { base.OutboundCharset = adowaVirtualDirectory.OutboundCharset.Value; } if (adowaVirtualDirectory.UseGB18030 != null && adowaVirtualDirectory.UseGB18030.Value) { base.UseGB18030 = true; } else { base.UseGB18030 = false; } if (adowaVirtualDirectory.UseISO885915 != null && adowaVirtualDirectory.UseISO885915.Value) { base.UseISO885915 = true; } else { base.UseISO885915 = false; } base.InstantMessagingType = ((adowaVirtualDirectory.InstantMessagingType != null) ? adowaVirtualDirectory.InstantMessagingType.Value : InstantMessagingTypeOptions.None); this.defaultAcceptedDomain = session.GetDefaultAcceptedDomain(); this.publicFoldersEnabledOnThisVdir = (adowaVirtualDirectory.PublicFoldersEnabled ?? false); this.ExpirationTime = DateTime.UtcNow + Configuration.expirationPeriod; OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_ConfigurationSettingsUpdated, string.Empty, new object[] { virtualDirectory, webSiteName }); }
// 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); }
public override void ProcessTag(HtmlTagContext context, HtmlWriter writer) { bool flag = false; bool flag2 = false; bool flag3 = false; bool flag4 = false; string text = null; string text2 = null; string text3 = null; AttachmentLink attachmentLink = null; if (context.TagId == HtmlTagId.Link) { context.DeleteTag(); return; } if (context.TagId == HtmlTagId.Head) { if (this.owaContext.UserContext.IsBasicExperience || this.bodyFormat != BodyFormat.TextPlain) { context.WriteTag(true); return; } if (!context.IsEndTag) { context.WriteTag(true); context.InvokeCallbackForEndTag(); return; } writer.WriteStartTag(HtmlTagId.Style); writer.WriteText("div.PlainText "); if (ObjectClass.IsSmsMessage(this.objectClass)) { writer.WriteText(OwaPlainTextStyle.GetStyleFromUserOption(this.owaContext.UserContext.UserOptions)); } else { writer.WriteText(OwaPlainTextStyle.GetStyleFromCharset(this.charSet)); } writer.WriteEndTag(HtmlTagId.Style); context.WriteTag(true); return; } else { if (this.isOutputFragment && context.TagId == HtmlTagId.Form) { context.DeleteTag(); return; } if (context.TagId == HtmlTagId.Form || (!this.isOutputFragment && OwaSafeHtmlOutboundCallbacks.IsFormElementTag(context.TagId))) { this.ProcessUnfragFormTagContext(context, writer); return; } if (context.TagId == HtmlTagId.Base) { foreach (HtmlTagContextAttribute attribute in context.Attributes) { if (OwaSafeHtmlCallbackBase.IsBaseTag(context.TagId, attribute)) { string value = attribute.Value; this.baseRef = Utilities.TryParseUri(value); break; } } return; } foreach (HtmlTagContextAttribute filterAttribute in context.Attributes) { if (filterAttribute.Id == HtmlAttributeId.Src || filterAttribute.Id == HtmlAttributeId.Href) { if (context.TagId == HtmlTagId.Img && string.IsNullOrEmpty(filterAttribute.Value)) { return; } if (string.CompareOrdinal(filterAttribute.Value, this.inlineRTFattachmentScheme) == 0 || filterAttribute.Value.StartsWith(this.inlineHTMLAttachmentScheme, StringComparison.OrdinalIgnoreCase)) { attachmentLink = this.IsInlineImage(filterAttribute); if (attachmentLink == null) { return; } if (context.TagId != HtmlTagId.Img) { writer.WriteEmptyElementTag(HtmlTagId.Img); this.OutputInlineReference(filterAttribute, context, attachmentLink, writer); context.DeleteTag(false); context.DeleteInnerContent(); return; } flag2 = true; break; } else { if (string.CompareOrdinal(filterAttribute.Value, this.embeddedRTFImage) == 0) { this.hasRtfEmbeddedImages = true; break; } break; } } } context.WriteTag(); foreach (HtmlTagContextAttribute htmlTagContextAttribute in context.Attributes) { if (!this.isOutputFragment || htmlTagContextAttribute.Id != HtmlAttributeId.Name || !OwaSafeHtmlOutboundCallbacks.IsFormElementTag(context.TagId)) { if (htmlTagContextAttribute.Id == HtmlAttributeId.UseMap) { this.ProcessUseMapAttribute(htmlTagContextAttribute, context, writer); } else if (OwaSafeHtmlCallbackBase.IsUrlTag(context.TagId, htmlTagContextAttribute)) { if (!flag) { this.ProcessHtmlUrlTag(htmlTagContextAttribute, context, writer); flag = true; } } else if (OwaSafeHtmlCallbackBase.IsImageTag(context.TagId, htmlTagContextAttribute)) { if (htmlTagContextAttribute.Id == HtmlAttributeId.Src && attachmentLink != null) { this.OutputInlineReference(htmlTagContextAttribute, context, attachmentLink, writer); } else { if ((htmlTagContextAttribute.Id != HtmlAttributeId.Src || flag2) && (htmlTagContextAttribute.Id != HtmlAttributeId.DynSrc || flag3) && (htmlTagContextAttribute.Id != HtmlAttributeId.LowSrc || flag4)) { continue; } this.ProcessImageTag(htmlTagContextAttribute, context, writer); } if (htmlTagContextAttribute.Id == HtmlAttributeId.Src) { flag2 = true; } else if (htmlTagContextAttribute.Id == HtmlAttributeId.DynSrc) { flag3 = true; } else if (htmlTagContextAttribute.Id == HtmlAttributeId.LowSrc) { flag4 = true; } } else if (OwaSafeHtmlCallbackBase.IsBackgroundAttribute(htmlTagContextAttribute)) { if (this.isOutputFragment && context.TagId == HtmlTagId.Div) { attachmentLink = this.IsInlineImage(htmlTagContextAttribute); if (attachmentLink != null) { AttachmentPolicy.Level attachmentLevel = this.GetAttachmentLevel(attachmentLink); if (AttachmentPolicy.Level.Allow == attachmentLevel) { writer.WriteAttribute(HtmlAttributeId.Style, "background:url('" + this.GetInlineReferenceUrl(attachmentLevel, attachmentLink, writer) + "');"); } } } else { this.ProcessImageTag(htmlTagContextAttribute, context, writer); } } else if (!OwaSafeHtmlOutboundCallbacks.IsTargetTagInAnchor(context.TagId, htmlTagContextAttribute)) { if (OwaSafeHtmlCallbackBase.IsSanitizingAttribute(htmlTagContextAttribute)) { if (htmlTagContextAttribute.Id == HtmlAttributeId.Border) { text = htmlTagContextAttribute.Value; } else if (htmlTagContextAttribute.Id == HtmlAttributeId.Height) { text2 = htmlTagContextAttribute.Value; } else if (htmlTagContextAttribute.Id == HtmlAttributeId.Width) { text3 = htmlTagContextAttribute.Value; } } else { htmlTagContextAttribute.Write(); } } } } if (!string.IsNullOrEmpty(text2) && !string.IsNullOrEmpty(text3) && this.hasBlockedImagesInCurrentPass) { OwaSafeHtmlOutboundCallbacks.SanitizeImage(writer, text, text2, text3); } else if (!this.hasBlockedImagesInCurrentPass) { if (!string.IsNullOrEmpty(text2)) { writer.WriteAttribute(HtmlAttributeId.Height, text2); } if (!string.IsNullOrEmpty(text3)) { writer.WriteAttribute(HtmlAttributeId.Width, text3); } if (!string.IsNullOrEmpty(text)) { writer.WriteAttribute(HtmlAttributeId.Border, text); } } if (this.hasFoundNonLocalUrlInCurrentPass) { if (this.owaContext.UserContext.IsBasicExperience) { if (!this.hasFoundMailToUrlInCurrentPass || this.openMailtoInNewWindow) { this.WriteSafeTargetBlank(writer); } } else { this.WriteSafeTargetBlank(writer); } } this.hasBlockedImagesInCurrentPass = false; this.hasFoundNonLocalUrlInCurrentPass = false; this.hasFoundMailToUrlInCurrentPass = false; return; } }
internal AttachmentPolicy(string[] blockFileTypes, string[] blockMimeTypes, string[] forceSaveFileTypes, string[] forceSaveMimeTypes, string[] allowFileTypes, string[] allowMimeTypes, AttachmentPolicy.Level treatUnknownTypeAs, bool directFileAccessOnPublicComputersEnabled, bool directFileAccessOnPrivateComputersEnabled, bool forceWebReadyDocumentViewingFirstOnPublicComputers, bool forceWebReadyDocumentViewingFirstOnPrivateComputers, bool webReadyDocumentViewingOnPublicComputersEnabled, bool webReadyDocumentViewingOnPrivateComputersEnabled, string[] webReadyFileTypes, string[] webReadyMimeTypes, string[] webReadyDocumentViewingSupportedFileTypes, string[] webReadyDocumentViewingSupportedMimeTypes, bool webReadyDocumentViewingForAllSupportedTypes) { this.treatUnknownTypeAs = treatUnknownTypeAs; this.directFileAccessOnPublicComputersEnabled = directFileAccessOnPublicComputersEnabled; this.directFileAccessOnPrivateComputersEnabled = directFileAccessOnPrivateComputersEnabled; this.forceWebReadyDocumentViewingFirstOnPublicComputers = forceWebReadyDocumentViewingFirstOnPublicComputers; this.forceWebReadyDocumentViewingFirstOnPrivateComputers = forceWebReadyDocumentViewingFirstOnPrivateComputers; this.webReadyDocumentViewingOnPublicComputersEnabled = webReadyDocumentViewingOnPublicComputersEnabled; this.webReadyDocumentViewingOnPrivateComputersEnabled = webReadyDocumentViewingOnPrivateComputersEnabled; this.webReadyFileTypes = webReadyFileTypes; Array.Sort <string>(this.webReadyFileTypes); this.webReadyMimeTypes = webReadyMimeTypes; Array.Sort <string>(this.webReadyMimeTypes); this.webReadyDocumentViewingSupportedFileTypes = webReadyDocumentViewingSupportedFileTypes; Array.Sort <string>(this.webReadyDocumentViewingSupportedFileTypes); this.webReadyDocumentViewingSupportedMimeTypes = webReadyDocumentViewingSupportedMimeTypes; Array.Sort <string>(this.webReadyDocumentViewingSupportedMimeTypes); this.webReadyDocumentViewingForAllSupportedTypes = webReadyDocumentViewingForAllSupportedTypes; this.fileTypeLevels = AttachmentPolicy.LoadDictionary(blockFileTypes, forceSaveFileTypes, allowFileTypes); this.mimeTypeLevels = AttachmentPolicy.LoadDictionary(blockMimeTypes, forceSaveMimeTypes, allowMimeTypes); }
// Token: 0x06000718 RID: 1816 RVA: 0x000378E4 File Offset: 0x00035AE4 private static void SetAttachmentResponseHeaders(HttpContext httpContext, string fileName, string contentType, bool isInline, AttachmentPolicy.Level level) { if (level == AttachmentPolicy.Level.ForceSave) { httpContext.Response.AppendHeader("X-Download-Options", "noopen"); } AttachmentUtility.SetContentDispositionResponseHeader(httpContext, fileName, isInline); httpContext.Response.AppendHeader("Content-Type", contentType + "; authoritative=true;"); if (isInline && OwaContext.Current.UserContext.IsPublicLogon) { Utilities.MakePageNoCacheNoStore(httpContext.Response); return; } httpContext.Response.Cache.SetExpires(AttachmentUtility.GetAttachmentExpiryDate()); }