forked from Ponysearch/Ponysearch
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
1 changed files with 7 additions and 1 deletions
|
@ -213,7 +213,13 @@ def get_engine_locale(searxng_locale, engine_locales, default=None):
|
||||||
# need to narrow language nor territory.
|
# need to narrow language nor territory.
|
||||||
return engine_locale
|
return engine_locale
|
||||||
|
|
||||||
|
try:
|
||||||
locale = babel.Locale.parse(searxng_locale, sep='-')
|
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 ..
|
# SearXNG's selected locale is not supported by the engine ..
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue