Fix ignore_from handling
This commit is contained in:
@@ -31,7 +31,7 @@ from netaddr import IPAddress, IPNetwork, AddrFormatError
|
|||||||
class HeaderRule:
|
class HeaderRule:
|
||||||
"""HeaderRule to implement a rule to apply on e-mail headers."""
|
"""HeaderRule to implement a rule to apply on e-mail headers."""
|
||||||
|
|
||||||
def __init__(self, name, action, header, search="", value="", ignore_hosts=[], ignore_envfrom="", only_hosts=[], log=True):
|
def __init__(self, name, action, header, search="", value="", ignore_hosts=[], ignore_envfrom=None, only_hosts=[], log=True):
|
||||||
self.logger = logging.getLogger(__name__)
|
self.logger = logging.getLogger(__name__)
|
||||||
self.name = name
|
self.name = name
|
||||||
self._action = action
|
self._action = action
|
||||||
@@ -67,10 +67,11 @@ class HeaderRule:
|
|||||||
except AddrFormatError as e:
|
except AddrFormatError as e:
|
||||||
raise RuntimeError("unable to parse option 'ignore_hosts' of rule '{}': {}".format(name, e))
|
raise RuntimeError("unable to parse option 'ignore_hosts' of rule '{}': {}".format(name, e))
|
||||||
|
|
||||||
try:
|
if self.ignore_envfrom:
|
||||||
self.ignore_envfrom = re.compile(ignore_envfrom, re.IGNORECASE)
|
try:
|
||||||
except re.error as e:
|
self.ignore_envfrom = re.compile(ignore_envfrom, re.IGNORECASE)
|
||||||
raise RuntimeError("unable to parse option 'ignore_envfrom' of rule '{}': {}".format(name, e))
|
except re.error as e:
|
||||||
|
raise RuntimeError("unable to parse option 'ignore_envfrom' of rule '{}': {}".format(name, e))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
for index, only in enumerate(only_hosts):
|
for index, only in enumerate(only_hosts):
|
||||||
@@ -330,7 +331,7 @@ def main():
|
|||||||
# check if optional config options are present in config
|
# check if optional config options are present in config
|
||||||
defaults = {
|
defaults = {
|
||||||
"ignore_hosts": [],
|
"ignore_hosts": [],
|
||||||
"ignore_envfrom": "",
|
"ignore_envfrom": None,
|
||||||
"only_hosts": [],
|
"only_hosts": [],
|
||||||
"log": "true"
|
"log": "true"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user