From b68f94f35f05f9ce50981b694caa7106223da849 Mon Sep 17 00:00:00 2001 From: pitzm Date: Thu, 13 Feb 2025 11:20:23 +0100 Subject: [PATCH] =?UTF-8?q?EmailProfiler.Common:=20Liste=20der=20Anh=C3=A4?= =?UTF-8?q?nge=20einschr=C3=A4nken,=20so=20dass=20nur=20erlaubte=20Dateity?= =?UTF-8?q?pen=20enthalten=20sind.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/EmailProfiler.Common/clsWorkEmail.vb | 44 +++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/App/EmailProfiler.Common/clsWorkEmail.vb b/App/EmailProfiler.Common/clsWorkEmail.vb index 1e0332f..6a3bc73 100644 --- a/App/EmailProfiler.Common/clsWorkEmail.vb +++ b/App/EmailProfiler.Common/clsWorkEmail.vb @@ -944,7 +944,9 @@ Public Class clsWorkEmail Dim oAttachmentCount As Integer = 0 ' Anzahl gültige Anhänge Dim AttachmentPosition As Integer = 0 ' Position des Anhangs in der EMail - For Each oAttachment As MimeData In pCurrentMail.Mail.Attachments + Dim oAttachmentList As List(Of MimeData) = GetPurgedAttachmentList(pCurrentMail.Mail.Attachments, pAllowXMLReceipts) + + For Each oAttachment As MimeData In oAttachmentList _Logger.Info("Working on Attachment [{0}]", oAttachment.SafeFileName) AttachmentPosition += 1 @@ -1027,6 +1029,46 @@ Public Class clsWorkEmail End Function + ''' + ''' Holt aus alle Anhängen diejenigen raus, + ''' die einen erlaubten Dateianhang haben + ''' + ''' + ''' + ''' Liste der Dateien, die wir verarbeiten wollen, nothing im Fehlerfall + Private Function GetPurgedAttachmentList(pAttachmentList As IMimeDataReadOnlyCollection, pAllowXMLReceipts As Boolean) As List(Of MimeData) + + _Logger.Debug("GetPurgedAttachmentList()") + Try + + Dim retValue As List(Of MimeData) = New List(Of MimeData) + Dim oIsValidExtension As Boolean = False + + For Each oAttachment As MimeData In pAttachmentList + Dim lowerFilename = oAttachment.SafeFileName.ToLower + + If pAllowXMLReceipts = True Then + oIsValidExtension = _ValidFirstExtensions.Any(Function(ext) lowerFilename.EndsWith(ext)) + Else + oIsValidExtension = _ValidExtensions.Any(Function(ext) lowerFilename.EndsWith(ext)) + End If + + If oIsValidExtension = True Then + retValue.Add(oAttachment) + End If + Next + + _Logger.Debug("GetPurgedAttachmentList() retValue contains [{0}] attachments.", retValue.Count) + + Return retValue + + Catch ex As Exception + _Logger.Error(ex) + End Try + + Return Nothing + End Function + Private Sub WorkEmbeddedAttachments(pEmailAttachment As EmailAttachment, pGDPicturePDF As GdPicturePDF) Dim embeddedFileCount As Integer = pGDPicturePDF.GetEmbeddedFileCount()