From 0dde07cc211a04936486f0826634030e6ff2d323 Mon Sep 17 00:00:00 2001 From: Nicolas Gelot Date: Mon, 7 Jan 2019 23:44:05 +0100 Subject: [PATCH 1/3] Replace cgi.escape by html.escape This patch removes the deprecation warning, "cgi.escape is deprecated, use html.escape instead". --- searx/webapp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/searx/webapp.py b/searx/webapp.py index aad67777e..5d964780b 100644 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -46,7 +46,7 @@ except: from sys import exit exit(1) -from cgi import escape +from html import escape from datetime import datetime, timedelta from werkzeug.contrib.fixers import ProxyFix from flask import ( -- GitLab From db62af272c4745c9c1787916f51e3f84e036b3f2 Mon Sep 17 00:00:00 2001 From: Nicolas Gelot Date: Mon, 7 Jan 2019 23:44:05 +0100 Subject: [PATCH 2/3] Fix invalid type of engines during merge result Engines was stored in set and casted in list, it leads to issue during merge of result. This patch fixes the engines container to a list to be able to use json serialization. Below the error spotted: ``` File "/usr/local/searx/searx/results.py", line 233, in _merge_result duplicated['engines'].add(result['engine']) AttributeError: 'list' object has no attribute 'add' ``` --- searx/results.py | 7 ++++--- searx/search_database.py | 3 --- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/searx/results.py b/searx/results.py index cb204a682..ab1c83e19 100644 --- a/searx/results.py +++ b/searx/results.py @@ -203,14 +203,14 @@ class ResultContainer(object): result['parsed_url'] = result['parsed_url']._replace(scheme="http") result['url'] = result['parsed_url'].geturl() - result['engines'] = set([result['engine']]) + result['engines'] = [result['engine']] # strip multiple spaces and cariage returns from content if result.get('content'): result['content'] = WHITESPACE_REGEX.sub(' ', result['content']) # check for duplicates - duplicated = False + duplicated = None for merged_result in self._merged_results: if compare_urls(result['parsed_url'], merged_result['parsed_url'])\ and result.get('template') == merged_result.get('template'): @@ -233,7 +233,8 @@ class ResultContainer(object): duplicated['positions'].append(position) # add engine to list of result-engines - duplicated['engines'].add(result['engine']) + if result['engine'] not in duplicated['engines']: + duplicated['engines'].append(result['engine']) # using https if possible if duplicated['parsed_url'].scheme != 'https' and result['parsed_url'].scheme == 'https': diff --git a/searx/search_database.py b/searx/search_database.py index f2267ef84..fea98d5f9 100644 --- a/searx/search_database.py +++ b/searx/search_database.py @@ -118,9 +118,6 @@ def get_search_data(q, r): results_number = 0 results = r.get_ordered_results() for result in results: - result['engines'] = list(result['engines']) - if not type(result['engines']) is list: - print(result['engines']) if 'publishedDate' in result: try: result['pubdate'] = result['publishedDate'].strftime('%Y-%m-%d %H:%M:%S') -- GitLab From 485e4671bb23473af63d324c5d8b6e4cb7e0a0a6 Mon Sep 17 00:00:00 2001 From: Nicolas Gelot Date: Mon, 7 Jan 2019 23:44:05 +0100 Subject: [PATCH 3/3] Remove debug statement --- searx/webapp.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/searx/webapp.py b/searx/webapp.py index 5d964780b..6285f2117 100644 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -486,8 +486,6 @@ def index(): # search search_data = None try: - print(request.form) - if is_general_first_page: request.form['categories'] = ['general', 'videos', 'images'] else: -- GitLab