hs: handle case where query is <= 2 characters

This commit is contained in:
mutantmonkey
2013-09-07 15:58:47 -07:00
parent cac9258c86
commit b8dde03000
2 changed files with 12 additions and 0 deletions

View File

@@ -21,6 +21,11 @@ def search(query):
except (web.ConnectionError, web.HTTPError):
raise GrumbleError("THE INTERNET IS FUCKING BROKEN. Please try again later.")
# apparently the failure mode if you search for <3 characters is a blank
# XML page...
if len(r) <= 0:
return False
xml = lxml.etree.fromstring(r.encode('utf-8'))
results = xml.findall('{0}directory-entries/{0}entry'.format(NS))
if len(results) <= 0: