1
0
mirror of https://github.com/searxng/searxng.git synced 2024-11-05 04:40:11 +01:00
searxng/searx
Markus Heiser 87e4c47621 [fix] url_for(..., _external=True) in templates
The `url_for` function in the template context is not the one from Flask, it is
the one from `webapp`.  The `webapp.url_for_theme` is different from its
namesake of Flask and has it quirks, when called with argument `_external=True`.

The `webapp.url_for_theme` can't handle absolute URLs since it pokes a leading
'/', here is the snippet of the old code::

    url = url_for(endpoint, **values)
    if settings['server']['base_url']:
        if url.startswith('/'):
            url = url[1:]
        url = urljoin(settings['server']['base_url'], url)

Next drawback of (Flask's) `_external=True` is, that it will not return the HTTP
scheme when searx (the Flask app) listens on http and is proxied by a https
server.

To get the right scheme `HTTP_X_SCHEME` is needed by Flask (werkzeug).  Since
this is not provided in every environment (e.g. behind Apache mod_wsgi or the
HTTP header is not fully set for some other reasons) it is recommended to
get *script_name*, *server* and *scheme* from the configured `base_url`.  If
`base_url` is specified, then these values from are given preference over any
Flask's generics.

BTW this patch normalize to use `url_for` in the `opensearch.xml` and drop the
need of `host` and `urljoin` in template's context.

Signed-off-by: Markus Heiser <markus@darmarit.de>
2021-04-05 14:34:45 +02:00
..
answerers [fix] answers: don't crash when the query is an empty string 2021-03-01 10:52:39 +01:00
data Merge pull request #2631 from searx/update_data_update_languages.py 2021-03-06 10:03:00 +01:00
engines Merge pull request #2626 from mikeri/solidtorrents 2021-03-12 19:45:22 +01:00
metrology [fix] checker: fix engine statistics 2021-01-18 08:19:44 +01:00
plugins [mod] pylint: numerous minor code fixes 2020-12-01 15:21:19 +01:00
search [mod] by default allow only HTTPS, not HTTP 2021-03-08 11:35:08 +01:00
shared [fix] checker: don't run the checker when uwsgi is not properly configured 2021-01-13 14:07:39 +01:00
static [mod] oscar: update README.rst 2021-03-11 09:33:04 +01:00
templates [fix] url_for(..., _external=True) in templates 2021-04-05 14:34:45 +02:00
translations [enh] update translations 2020-07-09 15:15:52 +02:00
__init__.py [mod] settings.yml: move brand settings to a dedicated section 2021-01-11 22:59:52 +01:00
autocomplete.py [enh] autocomplete refactoring, autocomplete on external bangs 2021-03-01 19:12:32 +01:00
exceptions.py [enh] add raise_for_httperror 2020-12-11 14:37:08 +01:00
external_bang.py [mod] add utils/fetch_external_bangs.py 2021-02-24 18:48:36 +01:00
external_urls.py [mod] add external_urls.json and wikidata_units.json 2020-10-28 08:09:25 +01:00
languages.py Update searx.data - update_languages.py 2021-03-05 10:56:46 +00:00
poolrequests.py [mod] by default allow only HTTPS, not HTTP 2021-03-08 11:35:08 +01:00
preferences.py Patch advanced search preferences 2020-11-23 19:13:29 +01:00
query.py [enh] autocomplete refactoring, autocomplete on external bangs 2021-03-01 19:12:32 +01:00
raise_for_httperror.py [enh] add raise_for_httperror 2020-12-11 14:37:08 +01:00
results.py [enh] add ability to send engine data to subsequent requests 2021-03-06 12:12:35 +01:00
settings_loader.py [fix] pylint: use "raise ... from ..." 2020-12-20 09:46:53 +01:00
settings_robot.yml Let admins lock user preferences 2020-10-25 18:06:18 +01:00
settings.yml Merge pull request #2626 from mikeri/solidtorrents 2021-03-12 19:45:22 +01:00
testing.py [py2to3] use unittest from py3, remove unittest2 from py2 2021-02-28 11:37:06 +01:00
utils.py [fix] pylint: use "raise ... from ..." 2020-12-20 09:46:53 +01:00
version.py prepare release 0.18.0 2020-12-14 19:03:09 +01:00
webadapter.py [enh] add ability to send engine data to subsequent requests 2021-03-06 12:12:35 +01:00
webapp.py [fix] url_for(..., _external=True) in templates 2021-04-05 14:34:45 +02:00
webutils.py Updated webutils.highlight_content to ignore double-quotes when highlighting query parts 2021-02-08 23:58:54 -05:00