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:
{# Show a note if there has been no results #}
{% else %}
- <div class="notification has-text-centered">
- {{ _("There are no matches for '%s'") % q }}
+ <div class="content has-text-centered">
+ <p>
+ {{ _("There are no matches for '%s'") % q }}
+ </p>
</div>
+
+ {# If the query has been a valid FQDN, we encourage users to report it #}
+ {% if results == {} %}
+ {% module DBLSubmitReport(name=q) %}
+ {% end %}
{% end %}
</div>
</section>
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)