|
@@ -1,6 +1,13 @@
|
|
1
|
+from base64 import urlsafe_b64encode, urlsafe_b64decode
|
|
2
|
+from zlib import compress, decompress
|
|
3
|
+from sys import version
|
|
4
|
+
|
1
|
5
|
from searx import settings, autocomplete
|
2
|
6
|
from searx.languages import language_codes as languages
|
3
|
|
-from searx.url_utils import urlencode
|
|
7
|
+from searx.url_utils import parse_qs, urlencode
|
|
8
|
+
|
|
9
|
+if version[0] == '3':
|
|
10
|
+ unicode = str
|
4
|
11
|
|
5
|
12
|
|
6
|
13
|
COOKIE_MAX_AGE = 60 * 60 * 24 * 365 * 5 # 5 years
|
|
@@ -279,7 +286,11 @@ class Preferences(object):
|
279
|
286
|
settings_kv['disabled_plugins'] = ','.join(self.plugins.disabled)
|
280
|
287
|
settings_kv['enabled_plugins'] = ','.join(self.plugins.enabled)
|
281
|
288
|
|
282
|
|
- return urlencode(settings_kv)
|
|
289
|
+ return urlsafe_b64encode(compress(urlencode(settings_kv).encode('utf-8'))).decode('utf-8')
|
|
290
|
+
|
|
291
|
+ def parse_encoded_data(self, input_data):
|
|
292
|
+ decoded_data = decompress(urlsafe_b64decode(input_data.encode('utf-8')))
|
|
293
|
+ self.parse_dict({x: y[0] for x,y in parse_qs(unicode(decoded_data)).items()})
|
283
|
294
|
|
284
|
295
|
def parse_dict(self, input_data):
|
285
|
296
|
for user_setting_name, user_setting in input_data.items():
|