From: Michael Tremer Date: Mon, 22 Dec 2025 10:20:49 +0000 (+0000) Subject: sources: Parse plain lists that include comments X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c84d6c83bcc371e4a87b70c94c37ac42c1ef0b52;p=dbl.git sources: Parse plain lists that include comments Signed-off-by: Michael Tremer --- diff --git a/src/dnsbl/sources.py b/src/dnsbl/sources.py index 77f5102..b272525 100644 --- a/src/dnsbl/sources.py +++ b/src/dnsbl/sources.py @@ -204,7 +204,7 @@ class Source(sqlmodel.SQLModel, database.BackendMixin, table=True): domain = self._process_hosts(line) case Format.PLAIN: - domain = line + domain = self._process_plain(line) # Skip the line if could not find the right format case _: @@ -342,6 +342,14 @@ class Source(sqlmodel.SQLModel, database.BackendMixin, table=True): """ return line.removeprefix("0.0.0.0 ") + def _process_plain(self, line): + """ + Parses a plain list of domains + """ + domain, _, comment = line.partition("#") + + return domain + def add_domains(self, domains): """ Adds or updates a domain.