From af74a159c34b0d9084455712736a55b7d18f65a3 Mon Sep 17 00:00:00 2001 From: kiskaadee Date: Sat, 21 Nov 2026 17:17:04 -0500 Subject: [PATCH] fix(CR-01): validate http/https protocol before rendering Zoom URLs in index.html - Add safeHttpUrl(url) helper in app/templates/index.html rejecting non-http(s) protocols - Render plain-text fallback when zoom_join_url or zoom_start_url fails protocol validation - Add test in tests/test_app.py verifying safeHttpUrl validation is used on link sinks --- app/templates/index.html | 21 +++++++++++++++++++-- tests/test_app.py | 13 +++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/app/templates/index.html b/app/templates/index.html index ef2ac03..3cd788b 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -119,6 +119,15 @@ .replace(/"/g, """); } + function safeHttpUrl(url) { + try { + const parsed = new URL(String(url ?? "")); + return parsed.protocol === "http:" || parsed.protocol === "https:" ? parsed.href : null; + } catch { + return null; + } + } + function readCredentialsFromInputs() { return { account_id: document.getElementById("zoom-account-id").value.trim(), @@ -265,11 +274,19 @@ `; } else { + const safeJoinUrl = safeHttpUrl(appt.zoom_join_url); + const safeStartUrl = safeHttpUrl(appt.zoom_start_url); + const joinLinkHtml = safeJoinUrl + ? `${escapeHtml(safeJoinUrl)}` + : `${escapeHtml(appt.zoom_join_url || "No disponible")}`; + const startLinkHtml = safeStartUrl + ? `Abrir como anfitriona (privado)` + : `Enlace no válido`; extraHtml = `
diff --git a/tests/test_app.py b/tests/test_app.py index 02d6514..073fe9f 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -554,3 +554,16 @@ def test_concurrent_pay_creates_only_one_zoom_meeting(tmp_path: Path, monkeypatc assert len(create_calls) == 1 assert sorted(statuses) == [200, 409] + + +def test_index_validates_http_urls_before_rendering_links(client): + test_client, _ = client + resp = test_client.get("/") + assert resp.status_code == 200 + html = resp.get_data(as_text=True) + assert "function safeHttpUrl(" in html + assert 'parsed.protocol === "http:" || parsed.protocol === "https:"' in html + assert "safeHttpUrl(appt.zoom_join_url)" in html + assert "safeHttpUrl(appt.zoom_start_url)" in html + assert 'href="${escapeHtml(appt.zoom_join_url)}"' not in html + assert 'href="${escapeHtml(appt.zoom_start_url)}"' not in html