From: Michael Tremer Date: Mon, 2 Mar 2026 17:17:49 +0000 (+0000) Subject: sources: Fail if we are trying to import some HTML X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=680412224feb9dcd3581dd456664835f08b977f2;p=dbl.git sources: Fail if we are trying to import some HTML Signed-off-by: Michael Tremer --- diff --git a/src/dbl/sources.py b/src/dbl/sources.py index 8f9bfb4..1094886 100644 --- a/src/dbl/sources.py +++ b/src/dbl/sources.py @@ -247,7 +247,14 @@ class Source(sqlmodel.SQLModel, database.BackendMixin, table=True): # Detect the format if still unknown if format is None: - format = self._detect_format(line) + try: + format = self._detect_format(line) + + # Log a warning if we have detected some invalid format + except Exception as e: + log.warning("Format detection failed for %s: %s" % (self.url, e)) + + return False # Process the line according to its format match format: @@ -454,6 +461,10 @@ class Source(sqlmodel.SQLModel, database.BackendMixin, table=True): elif util.is_fqdn(line): return Format.PLAIN + # Fail if we have received a HTML document + if line.startswith("<"): + raise ValueError("Source seems to be in HTML format") + # The format is (still?) unknown return None