summaryrefslogtreecommitdiff
path: root/searx/preferences.py
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2020-10-01 11:29:31 +0200
committerAlexandre Flament <alex@al-f.net>2020-10-01 11:29:31 +0200
commit507896c1159ae72dc1e45a4d0cf40f4654209ec0 (patch)
tree28b991a13f5ce9b562c33d6c4554834911dde083 /searx/preferences.py
parentfd5fe369844e481aecc0d731b08ee8b29c9b47e6 (diff)
[mod] preferences.py: check language setting with a regex instead of match_language
Diffstat (limited to 'searx/preferences.py')
-rw-r--r--searx/preferences.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/searx/preferences.py b/searx/preferences.py
index 3042636a6..f149dc976 100644
--- a/searx/preferences.py
+++ b/searx/preferences.py
@@ -10,7 +10,7 @@ from urllib.parse import parse_qs, urlencode
from searx import settings, autocomplete
from searx.languages import language_codes as languages
-from searx.utils import match_language
+from searx.webutils import VALID_LANGUAGE_CODE
COOKIE_MAX_AGE = 60 * 60 * 24 * 365 * 5 # 5 years
@@ -162,9 +162,7 @@ class SearchLanguageSetting(EnumStringSetting):
"""Available choices may change, so user's value may not be in choices anymore"""
def _validate_selection(self, selection):
- if selection != "" and not match_language(
- # pylint: disable=no-member
- selection, self.choices, fallback=None):
+ if selection != '' and not VALID_LANGUAGE_CODE.match(selection):
raise ValidationException('Invalid language code: "{0}"'.format(selection))
def parse(self, data):
@@ -181,6 +179,7 @@ class SearchLanguageSetting(EnumStringSetting):
data = lang
else:
data = self.value
+ self._validate_selection(data)
self.value = data