diff --git a/searx/webapp.py b/searx/webapp.py index 2f27d0f64..cc0624437 100755 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -81,6 +81,7 @@ from searx.webutils import ( is_hmac_of, is_flask_run_cmdline, group_engines_in_tab, + is_math, ) from searx.webadapter import ( get_search_query_from_webapp, @@ -851,7 +852,8 @@ def search(): ), theme = get_current_theme_name(), favicons = global_favicons[themes.index(get_current_theme_name())], - timeout_limit = request.form.get('timeout_limit', None) + timeout_limit = request.form.get('timeout_limit', None), + is_math = is_math(search_query.query) # fmt: on ) diff --git a/searx/webutils.py b/searx/webutils.py index 5be721eec..e281f1a43 100644 --- a/searx/webutils.py +++ b/searx/webutils.py @@ -179,3 +179,16 @@ def group_engines_in_tab(engines: Iterable[Engine]) -> List[Tuple[str, Iterable[ return (engine.about.get('language', ''), engine.name) return [(groupname, sorted(engines, key=engine_sort_key)) for groupname, engines in sorted_groups] + +def is_math(query): + is_math = False + characters = set(['1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '*', '/', '^', '%', '.', '+', '-', ',']) + numbers = 0 + + for i in query: + if i in characters: + numbers +=1 + + if len(query) < numbers+1: + is_math = True + return is_math \ No newline at end of file