Skip to content

Commit

Permalink
display if an engine does not support https
Browse files Browse the repository at this point in the history
Closes searx#302
  • Loading branch information
kvch committed Dec 9, 2020
1 parent 42a1948 commit 8f50429
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 11 deletions.
25 changes: 25 additions & 0 deletions searx/engines/__init__.py
Expand Up @@ -20,6 +20,7 @@
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
Expand Down Expand Up @@ -126,6 +127,30 @@ def load_engine(engine_data):

setattr(engine, 'language_aliases', language_aliases)

# 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': False,
'language': '',
'safesearch': False,
'is_test': True,
'category': 'files',
'raise_for_status': True,
})

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

setattr(engine, 'https_support', https_support)

# assign language fetching method if auxiliary method exists
if hasattr(engine, '_fetch_supported_languages'):
setattr(engine, 'fetch_supported_languages',
Expand Down
4 changes: 2 additions & 2 deletions searx/engines/acgsou.py
Expand Up @@ -18,7 +18,7 @@
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)]'
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion searx/engines/arxiv.py
Expand Up @@ -19,7 +19,7 @@
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
Expand Down
4 changes: 2 additions & 2 deletions searx/templates/oscar/macros.html
@@ -1,6 +1,6 @@
<!-- Draw glyphicon icon from bootstrap-theme -->
{% macro icon(action) -%}
<span class="glyphicon glyphicon-{{ action }}"></span>
{% macro icon(action, alt) -%}
<span title="{{ alt }}" class="glyphicon glyphicon-{{ action }}"></span>
{%- endmacro %}

<!-- Draw favicon -->
Expand Down
4 changes: 2 additions & 2 deletions searx/templates/oscar/preferences.html
Expand Up @@ -230,8 +230,8 @@ <h3>{{ _('Engines') }}</h3>
<td class="onoff-checkbox">
{{ checkbox_toggle('engine_' + search_engine.name|replace(' ', '_') + '__' + categ|replace(' ', '_'), (search_engine.name, categ) in disabled_engines) }}
</td>
<th scope="row">{{ search_engine.name }}</th>
<td class="name">{{ shortcuts[search_engine.name] }}</td>
<th scope="row">{% if not search_engine.https_support %}{{ icon('exclamation-sign', 'No HTTPS') }}{% endif %} {{ search_engine.name }}</td></th>
<td class="name">{{ shortcuts[search_engine.name] }}
<td>{{ support_toggle(stats[search_engine.name].supports_selected_language) }}</td>
<td>{{ support_toggle(search_engine.safesearch==True) }}</td>
<td>{{ support_toggle(search_engine.time_range_support==True) }}</td>
Expand Down
4 changes: 2 additions & 2 deletions searx/templates/simple/macros.html
@@ -1,6 +1,6 @@
<!-- Draw glyphicon icon from bootstrap-theme -->
{% macro icon(action) -%}
<span class="ion-icon-big ion-{{ action }}"></span>
{% macro icon(action, alt) -%}
<span title="{{ alt }}" class="ion-icon-big ion-{{ action }}"></span>
{%- endmacro %}

{% macro icon_small(action) -%}
Expand Down
4 changes: 2 additions & 2 deletions searx/templates/simple/preferences.html
@@ -1,4 +1,4 @@
{% from 'simple/macros.html' import tabs_open, tabs_close, tab_header, tab_footer, checkbox_onoff, checkbox %}
{% from 'simple/macros.html' import icon, tabs_open, tabs_close, tab_header, tab_footer, checkbox_onoff, checkbox %}

{% extends "simple/base.html" %}

Expand Down Expand Up @@ -121,7 +121,7 @@ <h2>{{ _('Preferences') }}</h2>
{% set engine_id = 'engine_' + search_engine.name|replace(' ', '_') + '__' + categ|replace(' ', '_') %}
<tr>
<td class="engine_checkbox">{{ checkbox_onoff(engine_id, (search_engine.name, categ) in disabled_engines) }}</td>
<th class="name">{{ search_engine.name }}</th>
<th class="name">{% if not search_engine.https_support %}{{ icon('exclamation-sign', 'No HTTPS') }}{% endif %} {{ search_engine.name }}</th>
<td class="shortcut">{{ shortcuts[search_engine.name] }}</td>
<td>{{ checkbox(engine_id + '_supported_languages', current_language == 'all' or current_language in search_engine.supported_languages or current_language.split('-')[0] in search_engine.supported_languages, true, true) }}</td>
<td>{{ checkbox(engine_id + '_safesearch', search_engine.safesearch==True, true, true) }}</td>
Expand Down

0 comments on commit 8f50429

Please sign in to comment.