Use the index's url for the root url in Search

Instead of using the requests root url, as flask for some reason uses http by default, even if the instance is https. Enforces https only if HTTPS_ONLY is set.
This commit is contained in:
DUO Labs 2022-06-24 13:12:57 -04:00 committed by GitHub
parent 877785c3ca
commit 28fd2f52d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,7 +7,7 @@ from app.request import gen_query
from app.utils.results import get_first_link from app.utils.results import get_first_link
from bs4 import BeautifulSoup as bsoup from bs4 import BeautifulSoup as bsoup
from cryptography.fernet import Fernet, InvalidToken from cryptography.fernet import Fernet, InvalidToken
from flask import g from flask import g, url_for
TOR_BANNER = '<hr><h1 style="text-align: center">You are using Tor</h1><hr>' TOR_BANNER = '<hr><h1 style="text-align: center">You are using Tor</h1><hr>'
CAPTCHA = 'div class="g-recaptcha"' CAPTCHA = 'div class="g-recaptcha"'
@ -117,7 +117,11 @@ class Search:
mobile = 'Android' in self.user_agent or 'iPhone' in self.user_agent mobile = 'Android' in self.user_agent or 'iPhone' in self.user_agent
content_filter = Filter(self.session_key, content_filter = Filter(self.session_key,
root_url=self.request.url_root, root_url=url_for('.index',
_external=True,
_scheme='https'
if os.getenv("HTTPS_ONLY",False)
else None),
mobile=mobile, mobile=mobile,
config=self.config, config=self.config,
query=self.query) query=self.query)