1
0
mirror of https://github.com/searxng/searxng.git synced 2024-11-22 20:17:45 +01:00
searxng/searx
Markus Heiser ef81d14ccf [fix] harden get_engine_locale: handle UnknownLocaleError exceptions
When a user selects an unknown or invalid locale by using the search syntax:

    !qw siemens :de-TW

Before this patch a UnknownLocaleError exception will be rasied:

```
Traceback (most recent call last):
  File "SearXNG/searx/search/processors/online.py", line 154, in search
    search_results = self._search_basic(query, params)
  File "SearXNG/searx/search/processors/online.py", line 128, in _search_basic
    self.engine.request(query, params)
  File "SearXNG/searx/engines/qwant.py", line 98, in request
    q_locale = get_engine_locale(params['language'], supported_languages, default='en_US')
  File "SearXNG/searx/locales.py", line 216, in get_engine_locale
    locale = babel.Locale.parse(searxng_locale, sep='-')
  File "SearXNG/local/py3/lib/python3.8/site-packages/babel/core.py", line 330, in parse
    raise UnknownLocaleError(input_id)
```

This patch implements a simple exception handling, since e.g. `de-TW` does not
exists `de` will be used to get engines locale.  On invalid terms like `xy-XY`
the default will be returned.

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2022-08-14 13:55:42 +02:00
..
answerers [fix] issue reported by pylint 22.1.0 2022-02-04 09:45:35 +01:00
data [fix] qwant - API error::locale must be one .. 2022-08-14 10:36:14 +02:00
engines [mod] qwant - add safesearch option 2022-08-14 10:36:14 +02:00
infopage Donation link: default value to searxng.org, can be hidden or custom 2022-07-02 11:29:21 +02:00
metrics [fix] prepare for pylint 2.14.0 2022-06-03 15:41:52 +02:00
network bing.py: resolve bing.com/ck/a redirections 2022-07-08 22:02:21 +02:00
plugins [mod] add tor_check plugin - convenient tor checking trough searxng 2022-07-19 07:34:54 +02:00
search [mod] add 'Accept-Language' HTTP header to online processores 2022-08-01 17:01:59 +02:00
shared [fix] typo in uWSGI cache: searxcache --> searxngcache 2022-08-07 12:31:09 +02:00
static [build] /static 2022-07-08 09:04:57 +02:00
templates/simple [fix] improve OpenSearch description 2022-08-11 19:04:36 +02:00
translations [translations] update from Weblate 2022-08-12 07:18:14 +00:00
__init__.py [format.python] initial formatting of the python code 2021-12-27 09:26:22 +01:00
autocomplete.py [format.python] based on bugfix in 9ed626130 2022-05-07 18:23:10 +02:00
babel_extract.py [mod] move category and names of constants to searx/searxng.msg 2022-03-16 09:55:53 +01:00
compat.py [fix] pyright repported errors 2022-07-30 18:04:44 +02:00
exceptions.py [pyright:strict] searx.search.checker.background 2022-01-27 22:07:12 +01:00
external_bang.py [fix] external bangs: don't overwrite Bangs in data trie 2022-01-12 19:37:13 +01:00
external_urls.py [format.python] initial formatting of the python code 2021-12-27 09:26:22 +01:00
flaskfix.py [format.python] initial formatting of the python code 2021-12-27 09:26:22 +01:00
languages.py [fix] add back missing languages & regions (followup of PR #1071) 2022-04-22 12:09:42 +02:00
locales.py [fix] harden get_engine_locale: handle UnknownLocaleError exceptions 2022-08-14 13:55:42 +02:00
preferences.py [fix] typo: add missing 'n' in center_aligment --> center_alignment 2022-07-03 17:35:54 +02:00
query.py [mod] add flags to the languages filter 2022-03-19 15:09:13 +01:00
redislib.py [mod] redislib - optimize LUA script registration. 2022-05-30 11:21:09 +02:00
results.py [simple theme] replace Image_layout.js with flexbox CS impl. 2022-02-26 22:31:47 +01:00
searxng.msg [mod] move category and names of constants to searx/searxng.msg 2022-03-16 09:55:53 +01:00
settings_defaults.py Merge pull request #1428 from return42/fix-center_aligment 2022-07-07 09:43:12 +02:00
settings_loader.py [format.python] initial formatting of the python code 2021-12-27 09:26:22 +01:00
settings.yml [mod] decouple qwant's categories from SearXNG's categories 2022-08-14 10:26:54 +02:00
unixthreadname.py [format.python] initial formatting of the python code 2021-12-27 09:26:22 +01:00
utils.py [fix] pyright repported errors 2022-07-30 18:04:44 +02:00
version.py [fix] pyright repported errors 2022-07-30 18:04:44 +02:00
webadapter.py [fix] disabling all engines in a category makes the bang search in general 2022-01-03 20:23:46 +01:00
webapp.py [fix] improve OpenSearch description 2022-08-11 19:04:36 +02:00
webutils.py theme: remove __common__ 2022-05-07 19:40:48 +02:00