on master help sign in
[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/<enginetype>.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

commit23d6c9c798cc6993a8a45dd96508428d7e9901a3 authorSimon Schuster <git@rationality.eu> dateWed 6 Oct 2021, 19:19 (5 years ago) parent49b2553
1 file changed+2−2
searx/engines/__init__.py+2−2
searx/engines/__init__.py+2−2
@@ -108,8 +108,8 @@ def load_engine(engine_data):
108108 sys.exit(1)
109109
110110 # assign supported languages from json file
111− if engine_data['name'] in ENGINES_LANGUAGES:
112− setattr(engine, 'supported_languages', ENGINES_LANGUAGES[engine_data['name']])
111+ if engine_data['engine'] in ENGINES_LANGUAGES:
112+ setattr(engine, 'supported_languages', ENGINES_LANGUAGES[engine_data['engine']])
113113
114114 # find custom aliases for non standard language codes
115115 if hasattr(engine, 'supported_languages'):