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
|
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(
|
def _process_attachments(
|
||||||
self,
|
self,
|
||||||
message: MailMessage,
|
message: MailMessage,
|
||||||
@ -682,12 +694,9 @@ class MailAccountHandler(LoggingMixin):
|
|||||||
f"does not match pattern {rule.filter_attachment_filename_include}",
|
f"does not match pattern {rule.filter_attachment_filename_include}",
|
||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
elif rule.filter_attachment_filename_exclude and fnmatch(
|
elif self._matchFilenameExlusion(
|
||||||
att.filename.lower(),
|
rule.filter_attachment_filename_exclude, att.filename
|
||||||
rule.filter_attachment_filename_exclude.lower(),
|
|
||||||
):
|
):
|
||||||
# Force the filename and pattern to the lowercase
|
|
||||||
# as this is system dependent otherwise
|
|
||||||
self.log.debug(
|
self.log.debug(
|
||||||
f"Rule {rule}: "
|
f"Rule {rule}: "
|
||||||
f"Skipping attachment {att.filename} "
|
f"Skipping attachment {att.filename} "
|
||||||
|
Loading…
x
Reference in New Issue
Block a user