Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3a63dfbd authored by Noémi Ványi's avatar Noémi Ványi
Browse files

display if an engine does not support https

Closes #302
parent 42a19489
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import sys
import threading
from os.path import realpath, dirname
from babel.localedata import locale_identifiers
from urllib.parse import urlparse
from flask_babel import gettext
from operator import itemgetter
from searx import settings
@@ -289,3 +290,34 @@ def initialize_engines(engine_list):
            if init_fn:
                logger.debug('%s engine: Starting background initialization', engine_name)
                threading.Thread(target=engine_init, args=(engine_name, init_fn)).start()

        _set_https_support_for_engine(engine)


def _set_https_support_for_engine(engine):
    # check HTTPS support if it is not disabled
    if not engine.offline and not hasattr(engine, 'https_support'):
        params = engine.request('http_test', {
            'method': 'GET',
            'headers': {},
            'data': {},
            'url': '',
            'cookies': {},
            'verify': True,
            'auth': None,
            'pageno': 1,
            'time_range': None,
            'language': '',
            'safesearch': False,
            'is_test': True,
            'category': 'files',
            'raise_for_status': True,
        })

        if 'url' not in params:
            return

        parsed_url = urlparse(params['url'])
        https_support = parsed_url.scheme == 'https'

        setattr(engine, 'https_support', https_support)
+2 −2
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ categories = ['files', 'images', 'videos', 'music']
paging = True

# search-url
base_url = 'http://www.acgsou.com/'
base_url = 'https://www.acgsou.com/'
search_url = base_url + 'search.php?{query}&page={offset}'
# xpath queries
xpath_results = '//table[contains(@class, "list_style table_fixed")]//tr[not(th)]'
@@ -40,7 +40,7 @@ def response(resp):
    for result in eval_xpath_list(dom, xpath_results):
        # defaults
        filesize = 0
        magnet_link = "magnet:?xt=urn:btih:{}&tr=http://tracker.acgsou.com:2710/announce"
        magnet_link = "magnet:?xt=urn:btih:{}&tr=https://tracker.acgsou.com:2710/announce"

        category = extract_text(eval_xpath_getindex(result, xpath_category, 0, default=[]))
        page_a = eval_xpath_getindex(result, xpath_title, 0)
+1 −1
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ from searx.utils import eval_xpath_list, eval_xpath_getindex
categories = ['science']
paging = True

base_url = 'http://export.arxiv.org/api/query?search_query=all:'\
base_url = 'https://export.arxiv.org/api/query?search_query=all:'\
           + '{query}&start={offset}&max_results={number_of_results}'

# engine dependent config
+1 −0
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ url = 'https://duckduckgo.com/js/spice/currency/1/{0}/{1}'
weight = 100

parser_re = re.compile('.*?(\\d+(?:\\.\\d+)?) ([^.0-9]+) (?:in|to) ([^.0-9]+)', re.I)
https_support = True


def normalize_name(name):
+1 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ weight = 100

parser_re = re.compile('.*?([a-z]+)-([a-z]+) ([^ ]+)$', re.I)
results_xpath = './/table[@id="r"]/tr'
https_support = True


def request(query, params):
Loading