Browse Source

[enh] allow morty proxy without hmac key

Adam Tauber 8 years ago
parent
commit
a67a4bf2c0
1 changed files with 7 additions and 3 deletions
  1. 7 3
      searx/webapp.py

+ 7 - 3
searx/webapp.py

@@ -253,11 +253,15 @@ def proxify(url):
     if not settings.get('result_proxy'):
         return url
 
-    h = hmac.new(settings['result_proxy']['key'], url.encode('utf-8'), hashlib.sha256).hexdigest()
+    url_params = dict(mortyurl=url.encode('utf-8'))
+
+    if settings['result_proxy'].get('key'):
+        url_params['mortyhash'] = hmac.new(settings['result_proxy']['key'],
+                                           url.encode('utf-8'),
+                                           hashlib.sha256).hexdigest()
 
     return '{0}?{1}'.format(settings['result_proxy']['url'],
-                            urlencode(dict(mortyurl=url.encode('utf-8'),
-                                           mortyhash=h)))
+                            urlencode(url_params))
 
 
 def image_proxify(url):