SearXNG is a free internet metasearch engine which aggregates results from various search services and databases. Users are neither tracked nor profiled.
Python bingbravedegoogleduckduckgogooglemetasearchprivacypythonqwantsearchsearch-enginesearxsearxngstartpageyahoo
[fix] calculator plugin: filtering real calculation tasks (#5016)
Markus Heisere851bc126991
diff --git a/searx/plugins/calculator.py b/searx/plugins/calculator.pyindex 5adaaaf22..428f734c1 100644--- a/searx/plugins/calculator.py+++ b/searx/plugins/calculator.py@@ -71,6 +71,22 @@ class SXNGPlugin(Plugin):# replace commonly used math operators with their proper Python operatorquery = query.replace("x", "*").replace(":", "/")+ # Is this a term that can be calculated?+ word, constants = "", set()+ for x in query:+ # Alphabetic characters are defined as "Letters" in the Unicode+ # character database and are the constants in an equation.+ if x.isalpha():+ word += x.strip()+ elif word:+ constants.add(word)+ word = ""++ # In the term of an arithmetic operation there should be no other+ # alphabetic characters besides the constants+ if constants - set(math_constants):+ return results+# use UI languageui_locale = babel.Locale.parse(request.preferences.get_value("locale"), sep="-")