diff --git a/README.md b/README.md index 1e620a0b51..6e917d1273 100644 --- a/README.md +++ b/README.md @@ -514,9 +514,10 @@ A lot of the app currently piggybacks on Google's existing support for fetching | Website | Country | Language | Cloudflare | |-|-|-|-| | [https://search.albony.xyz](https://search.albony.xyz/) | 🇮🇳 IN | Multi-choice | | -| [https://search.garudalinux.org](https://search.garudalinux.org) | 🇩🇪 DE | Multi-choice | | +| [https://search.garudalinux.org](https://search.garudalinux.org) | 🇫🇮 FI | Multi-choice | ✅ | +| [https://search.dr460nf1r3.org](https://search.dr460nf1r3.org) | 🇩🇪 DE | Multi-choice | ✅ | | [https://whooglesearch.net](https://whooglesearch.net) | 🇩🇪 DE | Spanish | | -| [https://s.alefvanoon.xyz](https://s.alefvanoon.xyz) | 🇺🇸 US | Multi-choice | ✅ | +| [https://s.tokhmi.xyz](https://s.tokhmi.xyz) | 🇺🇸 US | Multi-choice | ✅ | | [https://www.whooglesearch.ml](https://www.whooglesearch.ml) | 🇺🇸 US | English | | | [https://search.sethforprivacy.com](https://search.sethforprivacy.com) | 🇩🇪 DE | English | | | [https://whoogle.dcs0.hu](https://whoogle.dcs0.hu) | 🇭🇺 HU | Multi-choice | | diff --git a/app.json b/app.json index 0db750a029..64042c85a8 100644 --- a/app.json +++ b/app.json @@ -15,6 +15,11 @@ ], "stack": "container", "env": { + "WHOOGLE_URL_PREFIX": { + "description": "The URL prefix to use for the whoogle instance (i.e. \"/whoogle\")", + "value": "", + "required": false + }, "WHOOGLE_USER": { "description": "The username for basic auth. WHOOGLE_PASS must also be set if used. Leave empty to disable.", "value": "", diff --git a/app/__init__.py b/app/__init__.py index 0fdc86f8b3..a49de6159c 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -26,16 +26,24 @@ load_dotenv(os.path.join(os.path.dirname(os.path.abspath(__file__)), dotenv_path)) +# Session values +# NOTE: SESSION_COOKIE_SAMESITE must be set to 'lax' to allow the user's +# previous session to persist when accessing the instance from an external +# link. Setting this value to 'strict' causes Whoogle to revalidate a new +# session, and fail, resulting in cookies being disabled. +# +# This could be re-evaluated if Whoogle ever switches to client side +# configuration instead. app.default_key = generate_user_key() app.config['SECRET_KEY'] = os.urandom(32) app.config['SESSION_TYPE'] = 'filesystem' -app.config['SESSION_COOKIE_SAMESITE'] = 'strict' +app.config['SESSION_COOKIE_SAMESITE'] = 'Lax' if os.getenv('HTTPS_ONLY'): app.config['SESSION_COOKIE_NAME'] = '__Secure-session' app.config['SESSION_COOKIE_SECURE'] = True -app.config['VERSION_NUMBER'] = '0.7.1' +app.config['VERSION_NUMBER'] = '0.7.2' app.config['APP_ROOT'] = os.getenv( 'APP_ROOT', os.path.dirname(os.path.abspath(__file__))) diff --git a/app/filter.py b/app/filter.py index 24ba8a0dc4..457fdc1cf0 100644 --- a/app/filter.py +++ b/app/filter.py @@ -72,7 +72,7 @@ def clean_css(css: str, page_url: str) -> str: continue css = css.replace( url, - f'/element?type=image/png&url={abs_url}' + f'{Endpoint.element}?type=image/png&url={abs_url}' ) return css @@ -410,8 +410,10 @@ def update_link(self, link: Tag) -> None: None (the tag is updated directly) """ + link_netloc = urlparse.urlparse(link['href']).netloc + # Remove any elements that direct to unsupported Google pages - if any(url in link['href'] for url in unsupported_g_pages): + if any(url in link_netloc for url in unsupported_g_pages): # FIXME: The "Shopping" tab requires further filtering (see #136) # Temporarily removing all links to that tab for now. parent = link.parent @@ -466,7 +468,8 @@ def update_link(self, link: Tag) -> None: if href.startswith(MAPS_URL): # Maps links don't work if a site filter is applied link['href'] = MAPS_URL + "?q=" + clean_query(q) - elif href.startswith('/?') or href.startswith('/search?'): + elif (href.startswith('/?') or href.startswith('/search?') or + href.startswith('/imgres?')): # make sure that tags can be clicked as relative URLs link['href'] = href[1:] elif href.startswith('/intl/'): diff --git a/app/routes.py b/app/routes.py index aa84a43596..5b732510cd 100644 --- a/app/routes.py +++ b/app/routes.py @@ -432,22 +432,6 @@ def config(): return redirect(url_for('.index'), code=403) -@app.route(f'/{Endpoint.url}', methods=['GET']) -@session_required -@auth_required -def url(): - if 'url' in request.args: - return redirect(request.args.get('url')) - - q = request.args.get('q') - if len(q) > 0 and 'http' in q: - return redirect(q) - else: - return render_template( - 'error.html', - error_message='Unable to resolve query: ' + q) - - @app.route(f'/{Endpoint.imgres}') @session_required @auth_required @@ -536,7 +520,7 @@ def window(): # Use anonymous view for all links on page for a in results.find_all('a', {'href': True}): - a['href'] = '/window?location=' + a['href'] + ( + a['href'] = f'{Endpoint.window}?location=' + a['href'] + ( '&nojs=1' if 'nojs' in request.args else '') # Remove all iframes -- these are commonly used inside of