mirror of
https://github.com/searxng/searxng
synced 2024-11-09 01:10:26 +00:00
Merge pull request #1664 from return42/harden-get_engine_locales
[fix] harden get_engine_locale: handle UnknownLocaleError exceptions
This commit is contained in:
commit
649d1a144d
@ -213,7 +213,13 @@ def get_engine_locale(searxng_locale, engine_locales, default=None):
|
||||
# need to narrow language nor territory.
|
||||
return engine_locale
|
||||
|
||||
locale = babel.Locale.parse(searxng_locale, sep='-')
|
||||
try:
|
||||
locale = babel.Locale.parse(searxng_locale, sep='-')
|
||||
except babel.core.UnknownLocaleError:
|
||||
try:
|
||||
locale = babel.Locale.parse(searxng_locale.split('-')[1])
|
||||
except babel.core.UnknownLocaleError:
|
||||
return default
|
||||
|
||||
# SearXNG's selected locale is not supported by the engine ..
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user