From 1942119c4da58015fe4c3245527b55da9bc1c122 Mon Sep 17 00:00:00 2001 From: Nivesh Krishna Date: Tue, 12 Apr 2022 11:07:13 +0530 Subject: [PATCH 1/2] replace ^ with ** --- searx/plugins/calculator.py | 1 + 1 file changed, 1 insertion(+) diff --git a/searx/plugins/calculator.py b/searx/plugins/calculator.py index aa7a8b5c0..7d6475356 100644 --- a/searx/plugins/calculator.py +++ b/searx/plugins/calculator.py @@ -27,6 +27,7 @@ def post_search(request, search): try: query = search.search_query.query.lower() query = query.replace("x", "*") + query = query.replace("^", "**") # Not going to compute if only one number is present try: -- GitLab From 38fb37cf3e83541184e64fbfcb2dec6770dd4696 Mon Sep 17 00:00:00 2001 From: Nivesh Krishna Date: Tue, 12 Apr 2022 11:14:59 +0530 Subject: [PATCH 2/2] show unmodified query --- searx/plugins/calculator.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/searx/plugins/calculator.py b/searx/plugins/calculator.py index 7d6475356..f8a7eefa6 100644 --- a/searx/plugins/calculator.py +++ b/searx/plugins/calculator.py @@ -26,6 +26,7 @@ def post_search(request, search): return try: query = search.search_query.query.lower() + unmodified_query = query query = query.replace("x", "*") query = query.replace("^", "**") @@ -51,7 +52,7 @@ def post_search(request, search): value = evaluate(query).item() if type(value) in (int, float): search.result_container.answers.clear() - answer = "{} = {}".format(query, value) + answer = "{} = {}".format(unmodified_query, value) search.result_container.answers[answer] = {'answer': answer, 'calculator': True} except (ZeroDivisionError, ValueError, FloatingPointError, MemoryError, OverflowError) as e: answer = gettext('Error') -- GitLab