From 28fd2f52d5361c726cc4314515fae326d4310bcc Mon Sep 17 00:00:00 2001 From: DUO Labs Date: Fri, 24 Jun 2022 13:12:57 -0400 Subject: [PATCH] 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. --- app/utils/search.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/utils/search.py b/app/utils/search.py index ada83f4..6c38135 100644 --- a/app/utils/search.py +++ b/app/utils/search.py @@ -7,7 +7,7 @@ from app.request import gen_query from app.utils.results import get_first_link from bs4 import BeautifulSoup as bsoup from cryptography.fernet import Fernet, InvalidToken -from flask import g +from flask import g, url_for TOR_BANNER = '

You are using Tor


' CAPTCHA = 'div class="g-recaptcha"' @@ -117,7 +117,11 @@ class Search: mobile = 'Android' in self.user_agent or 'iPhone' in self.user_agent 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, config=self.config, query=self.query)