]> git.ipfire.org Git - dbl.git/commitdiff
sources: Parse plain lists that include comments
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 22 Dec 2025 10:20:49 +0000 (10:20 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 22 Dec 2025 10:20:49 +0000 (10:20 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/dnsbl/sources.py

index 77f510211a9f40675b255879b41c9d84d85ac23e..b272525e8f794121f3746c924a44f65fa2c485bc 100644 (file)
@@ -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.