From: Michael Tremer Date: Sat, 24 Jan 2026 15:40:19 +0000 (+0000) Subject: dbl: Encourage people to report a domain if it could not be found X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c8dd1a08fe4097d5ef85e53fe872d7fc24fc824a;p=ipfire.org.git dbl: Encourage people to report a domain if it could not be found Signed-off-by: Michael Tremer --- diff --git a/src/backend/dbl.py b/src/backend/dbl.py index 65bc2095..5693fad9 100644 --- a/src/backend/dbl.py +++ b/src/backend/dbl.py @@ -104,7 +104,15 @@ class DBL(Object): tasks = {} # Perform the search - result = await self._fetch("/search", args={ "q" : q }) + try: + result = await self._fetch("/search", args={ "q" : q }) + + # Catch anything that isn't a valid FQDN + except tornado.httpclient.HTTPClientError as e: + if e.code == 400: + raise ValueError("Not a valid FQDN: %s" % q) from e + + raise e # Fetch all lists async with asyncio.TaskGroup() as tg: diff --git a/src/templates/dbl/search.html b/src/templates/dbl/search.html index 67317f21..d0101c96 100644 --- a/src/templates/dbl/search.html +++ b/src/templates/dbl/search.html @@ -65,9 +65,16 @@ {# Show a note if there has been no results #} {% else %} -
- {{ _("There are no matches for '%s'") % q }} +
+

+ {{ _("There are no matches for '%s'") % q }} +

+ + {# If the query has been a valid FQDN, we encourage users to report it #} + {% if results == {} %} + {% module DBLSubmitReport(name=q) %} + {% end %} {% end %}
diff --git a/src/web/dbl.py b/src/web/dbl.py index 7c897254..543bab6c 100644 --- a/src/web/dbl.py +++ b/src/web/dbl.py @@ -156,7 +156,12 @@ class SearchHandler(base.AnalyticsMixin, BaseHandler): raise tornado.web.HTTPError(400, "Empty search query") # Search for the query - results = await self.backend.dbl.search(q) + try: + results = await self.backend.dbl.search(q) + + # ValueError is raised if the query has not been a valid FQDN + except ValueError as e: + results = None # Render the page self.render("dbl/search.html", q=q, results=results)