|
@@ -31,6 +31,8 @@ from pygments.formatters import HtmlFormatter # pylint: disable=no-name-in-modu
|
|
from werkzeug.middleware.proxy_fix import ProxyFix
|
|
from werkzeug.middleware.proxy_fix import ProxyFix
|
|
from werkzeug.serving import WSGIRequestHandler
|
|
from werkzeug.serving import WSGIRequestHandler
|
|
|
|
|
|
|
|
+import flask
|
|
|
|
+
|
|
from flask import (
|
|
from flask import (
|
|
Flask,
|
|
Flask,
|
|
request,
|
|
request,
|
|
@@ -86,6 +88,7 @@ from searx.utils import (
|
|
gen_useragent,
|
|
gen_useragent,
|
|
dict_subset,
|
|
dict_subset,
|
|
match_language,
|
|
match_language,
|
|
|
|
+ get_value,
|
|
)
|
|
)
|
|
from searx.version import VERSION_STRING
|
|
from searx.version import VERSION_STRING
|
|
from searx.query import RawTextQuery
|
|
from searx.query import RawTextQuery
|
|
@@ -161,6 +164,8 @@ for indice, theme in enumerate(themes):
|
|
for (dirpath, dirnames, filenames) in os.walk(theme_img_path):
|
|
for (dirpath, dirnames, filenames) in os.walk(theme_img_path):
|
|
global_favicons[indice].extend(filenames)
|
|
global_favicons[indice].extend(filenames)
|
|
|
|
|
|
|
|
+OUTPUT_FORMATS = ['html', 'csv', 'json', 'rss']
|
|
|
|
+
|
|
STATS_SORT_PARAMETERS = {
|
|
STATS_SORT_PARAMETERS = {
|
|
'name': (False, 'name', ''),
|
|
'name': (False, 'name', ''),
|
|
'score': (True, 'score', 0),
|
|
'score': (True, 'score', 0),
|
|
@@ -511,6 +516,11 @@ def render(template_name, override_theme=None, **kwargs):
|
|
|
|
|
|
kwargs['preferences'] = request.preferences
|
|
kwargs['preferences'] = request.preferences
|
|
|
|
|
|
|
|
+ kwargs['search_formats'] = [
|
|
|
|
+ x for x in get_value(
|
|
|
|
+ settings, 'search', 'formats', default=OUTPUT_FORMATS)
|
|
|
|
+ if x != 'html']
|
|
|
|
+
|
|
kwargs['brand'] = brand
|
|
kwargs['brand'] = brand
|
|
|
|
|
|
kwargs['translations'] = json.dumps(get_translations(), separators=(',', ':'))
|
|
kwargs['translations'] = json.dumps(get_translations(), separators=(',', ':'))
|
|
@@ -683,9 +693,12 @@ def search():
|
|
|
|
|
|
# output_format
|
|
# output_format
|
|
output_format = request.form.get('format', 'html')
|
|
output_format = request.form.get('format', 'html')
|
|
- if output_format not in ['html', 'csv', 'json', 'rss']:
|
|
|
|
|
|
+ if output_format not in OUTPUT_FORMATS:
|
|
output_format = 'html'
|
|
output_format = 'html'
|
|
|
|
|
|
|
|
+ if output_format not in get_value(settings, 'search', 'formats', default=OUTPUT_FORMATS):
|
|
|
|
+ flask.abort(403)
|
|
|
|
+
|
|
# check if there is query (not None and not an empty string)
|
|
# check if there is query (not None and not an empty string)
|
|
if not request.form.get('q'):
|
|
if not request.form.get('q'):
|
|
if output_format == 'html':
|
|
if output_format == 'html':
|