@@ -10,7 +10,7 @@ from urllib.parse import parse_qs, urlencode
1010
1111from searx import settings, autocomplete
1212from searx.languages import language_codes as languages
13−from searx.utils import match_language
13+from searx.webutils import VALID_LANGUAGE_CODE
1414
1515
1616COOKIE_MAX_AGE = 60 * 60 * 24 * 365 * 5 # 5 years
@@ -162,9 +162,7 @@ class SearchLanguageSetting(EnumStringSetting):
162162 """Available choices may change, so user's value may not be in choices anymore"""
163163
164164 def _validate_selection(self, selection):
165− if selection != "" and not match_language(
166− # pylint: disable=no-member
167− selection, self.choices, fallback=None):
165+ if selection != '' and not VALID_LANGUAGE_CODE.match(selection):
168166 raise ValidationException('Invalid language code: "{0}"'.format(selection))
169167
170168 def parse(self, data):
@@ -181,6 +179,7 @@ class SearchLanguageSetting(EnumStringSetting):
181179 data = lang
182180 else:
183181 data = self.value
182+ self._validate_selection(data)
184183 self.value = data
185184
186185