Split filter_attachment_filename_exclude by comma
This commit is contained in:
parent
1141c3f361
commit
cc68ee44d1
@ -646,6 +646,18 @@ class MailAccountHandler(LoggingMixin):
|
||||
|
||||
return processed_elements
|
||||
|
||||
def _matchFilenameExlusion(filter_attachment_filename_exclude, filename) -> bool:
|
||||
if filter_attachment_filename_exclude:
|
||||
filter_attachment_filename_exclusions = filter_attachment_filename_exclude.split(",")
|
||||
|
||||
# Force the filename and pattern to the lowercase
|
||||
# as this is system dependent otherwise
|
||||
filename = filename.lower()
|
||||
for filename_exclude in filter_attachment_filename_exclusions:
|
||||
if filename_exclude and fnmatch(filename, filename_exclude.lower()):
|
||||
return True
|
||||
return False
|
||||
|
||||
def _process_attachments(
|
||||
self,
|
||||
message: MailMessage,
|
||||
@ -682,12 +694,9 @@ class MailAccountHandler(LoggingMixin):
|
||||
f"does not match pattern {rule.filter_attachment_filename_include}",
|
||||
)
|
||||
continue
|
||||
elif rule.filter_attachment_filename_exclude and fnmatch(
|
||||
att.filename.lower(),
|
||||
rule.filter_attachment_filename_exclude.lower(),
|
||||
elif self._matchFilenameExlusion(
|
||||
rule.filter_attachment_filename_exclude, att.filename
|
||||
):
|
||||
# Force the filename and pattern to the lowercase
|
||||
# as this is system dependent otherwise
|
||||
self.log.debug(
|
||||
f"Rule {rule}: "
|
||||
f"Skipping attachment {att.filename} "
|
||||
|
Loading…
x
Reference in New Issue
Block a user