From 23d6c9c798cc6993a8a45dd96508428d7e9901a3 Mon Sep 17 00:00:00 2001 From: Simon Schuster Date: Wed, 6 Oct 2021 19:19:35 +0200 Subject: [PATCH] [fix] use engine-type when looking up supported_languages from JSON files searx/data/engines_languages.json stores language information for several searchengines in a json endoded dict that maps engine-"types" to their supported languages; for instance there is an entry "google", mapping to the supported languages of the google engine. However, the lookup code did not use the engine 'type' (as in: the filename searx/engines/.py), but instead the manually configured engine name from settings.yml when querying. This is problematic as soon as users start to specify additional engine instances with custom names in the config file, as for instance suggested as a workaround for multilingual search in the manual[0]: > engines: > - name : google english > engine : google > language : english Here, the engine name "google english" will be used for the lookup in the json file, which does not exist. The empty supported_languages then lead to a type error later in the processing callchain. This patch changes the behaviour to use the engine's entry-"type" ("google" in the above example) for the lookup. This should fix bug #2928. 0: https://searx.github.io/searx/user/search_syntax.html#multilingual-search --- searx/engines/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/searx/engines/__init__.py b/searx/engines/__init__.py index 95eda6dd..20fa5206 100644 --- a/searx/engines/__init__.py +++ b/searx/engines/__init__.py @@ -108,8 +108,8 @@ def load_engine(engine_data): sys.exit(1) # assign supported languages from json file - if engine_data['name'] in ENGINES_LANGUAGES: - setattr(engine, 'supported_languages', ENGINES_LANGUAGES[engine_data['name']]) + if engine_data['engine'] in ENGINES_LANGUAGES: + setattr(engine, 'supported_languages', ENGINES_LANGUAGES[engine_data['engine']]) # find custom aliases for non standard language codes if hasattr(engine, 'supported_languages'):