forked from zaclys/searxng
Merge pull request #2454 from MarcAbonce/fix-empty-lang-bang
Fix empty colon in query from selecting Chinese
This commit is contained in:
commit
c2646df496
|
@ -77,7 +77,7 @@ class RawTextQuery:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# this force a language
|
# this force a language
|
||||||
if query_part[0] == ':':
|
if query_part[0] == ':' and len(query_part) > 1:
|
||||||
lang = query_part[1:].lower().replace('_', '-')
|
lang = query_part[1:].lower().replace('_', '-')
|
||||||
|
|
||||||
# check if any language-code is equal with
|
# check if any language-code is equal with
|
||||||
|
|
|
@ -59,6 +59,15 @@ class TestQuery(SearxTestCase):
|
||||||
self.assertEqual(len(query.languages), 0)
|
self.assertEqual(len(query.languages), 0)
|
||||||
self.assertFalse(query.specific)
|
self.assertFalse(query.specific)
|
||||||
|
|
||||||
|
def test_empty_colon_in_query(self):
|
||||||
|
query_text = 'the : query'
|
||||||
|
query = RawTextQuery(query_text, [])
|
||||||
|
|
||||||
|
self.assertEqual(query.getFullQuery(), query_text)
|
||||||
|
self.assertEqual(len(query.query_parts), 0)
|
||||||
|
self.assertEqual(len(query.languages), 0)
|
||||||
|
self.assertFalse(query.specific)
|
||||||
|
|
||||||
def test_timeout_below100(self):
|
def test_timeout_below100(self):
|
||||||
query_text = '<3 the query'
|
query_text = '<3 the query'
|
||||||
query = RawTextQuery(query_text, [])
|
query = RawTextQuery(query_text, [])
|
||||||
|
|
Loading…
Reference in New Issue