From bfda3746fdd94b601fb689a436951e02311c1a3f Mon Sep 17 00:00:00 2001 From: cato447 Date: Wed, 5 Nov 2025 17:15:29 +0100 Subject: [PATCH] removed comment that messes up the injection logic --- app/routes.py | 80 ++++++++++++++++++++-------------------- app/templates/index.html | 1 - debug.py | 2 +- 3 files changed, 41 insertions(+), 42 deletions(-) diff --git a/app/routes.py b/app/routes.py index 1f59b5c..a26839f 100644 --- a/app/routes.py +++ b/app/routes.py @@ -44,7 +44,7 @@ from .utils import ( main = Blueprint('main', __name__) -slidev_deck_pattern = re.compile(r"^\/slides\/[^\/]+\/\d*(?:\?.*)?$") +slidev_deck_pattern = re.compile(r"^\/slides\/[^\/]+\/[^\/]+\/(?:\d+|index\.html)(?:\?.*)?$") slidev_all_pattern = re.compile(r"^\/slides\/([^\/]+)\/([^\/]+)(?:\/presenter)?\/(\d+)(?:\?.*)?$") @socketio.on("connect") @@ -54,45 +54,45 @@ def on_connect(): @main.after_request def inject_confused_button(response): - if True: - if (slidev_deck_pattern.match(request.path) or request.path == '/') and response.content_type.startswith('text/html') and not flask_login.current_user.is_authenticated : - if response.direct_passthrough: - response.direct_passthrough = False - body = response.get_data(as_text=True) - insert_at = body.find('') - if insert_at != -1: - button_html = """ - - - """ - body = body[:insert_at] + button_html + body[insert_at:] - response.set_data(body) + if (slidev_deck_pattern.match(request.path) or request.path == '/') and response.content_type.startswith('text/html') and not flask_login.current_user.is_authenticated : + print("** INJECTION TEST PASSED **") + if response.direct_passthrough: + response.direct_passthrough = False + body = response.get_data(as_text=True) + insert_at = body.find('') + if insert_at != -1: + button_html = """ + + + """ + body = body[:insert_at] + button_html + body[insert_at:] + response.set_data(body) return response diff --git a/app/templates/index.html b/app/templates/index.html index 0b47ad0..e61479b 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -9,7 +9,6 @@ - diff --git a/debug.py b/debug.py index bc0b0f7..799d52a 100644 --- a/debug.py +++ b/debug.py @@ -3,4 +3,4 @@ from app import create_app, socketio app = create_app() if __name__ == '__main__': - socketio.run(app, host="0.0.0.0", port=5000, debug=True) + socketio.run(app, port=5000, debug=True)