chore: update global_search and add test
Signed-off-by: Chinmay D. Pai <chinmaydpai@gmail.com>
This commit is contained in:
parent
063def052e
commit
10e939d012
2 changed files with 5 additions and 2 deletions
|
|
@ -191,3 +191,6 @@ class TestGlobalSearch(unittest.TestCase):
|
|||
frappe.db.commit()
|
||||
results = global_search.web_search('unsubscribe')
|
||||
self.assertTrue('Unsubscribe' in results[0].content)
|
||||
results = global_search.web_search(text='manufacturing',
|
||||
scope="manufacturing\" UNION ALL SELECT 1,2,3,4,doctype from __global_search")
|
||||
self.assetTrue(results == [])
|
||||
|
|
|
|||
|
|
@ -501,7 +501,7 @@ def web_search(text, scope=None, start=0, limit=20):
|
|||
WHERE {conditions}
|
||||
LIMIT %(limit)s OFFSET %(start)s'''
|
||||
|
||||
scope_condition = '`route` like "%(scope)s" AND ' if scope else ''
|
||||
scope_condition = '`route` like %(scope)s AND ' if scope else ''
|
||||
published_condition = '`published` = 1 AND '
|
||||
mariadb_conditions = postgres_conditions = ' '.join([published_condition, scope_condition])
|
||||
|
||||
|
|
@ -514,7 +514,7 @@ def web_search(text, scope=None, start=0, limit=20):
|
|||
"scope": "".join([scope, "%"]) if scope else '',
|
||||
"limit": limit,
|
||||
"start": start,
|
||||
"text": frappe.db.escape(text)
|
||||
"text": text
|
||||
}
|
||||
|
||||
result = frappe.db.multisql({
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue