summaryrefslogtreecommitdiff
path: root/src/ollama_web/static/login.js
diff options
context:
space:
mode:
authorたかし <30774985+takashi000@users.noreply.github.com>2026-06-27 11:30:25 +0900
committerGitHub <noreply@github.com>2026-06-27 11:30:25 +0900
commitb7943a7586fbd0bb0e19aad7732c11a62f72d7c1 (patch)
treec036caab89143dda7a19478f830371c856b4ee2c /src/ollama_web/static/login.js
parent01583ab13d25d9c966c6adfa1da20b53d3bdbac8 (diff)
Potential fix for code scanning alert no. 1: Client-side URL redirect
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Diffstat (limited to 'src/ollama_web/static/login.js')
-rw-r--r--src/ollama_web/static/login.js6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/ollama_web/static/login.js b/src/ollama_web/static/login.js
index 648e219..1f91868 100644
--- a/src/ollama_web/static/login.js
+++ b/src/ollama_web/static/login.js
@@ -3,6 +3,7 @@
const form = document.getElementById("login-form");
const pinInput = document.getElementById("pin-input");
const errorEl = document.getElementById("login-error");
+const ALLOWED_NEXT_PATHS = new Set(["/", "/chat", "/settings"]);
form.addEventListener("submit", async (event) => {
event.preventDefault();
@@ -16,6 +17,7 @@ form.addEventListener("submit", async (event) => {
errorEl.textContent = "PINが違います";
return;
}
- const next = new URLSearchParams(window.location.search).get("next") || "/";
- window.location.assign(next.startsWith("/") ? next : "/");
+ const requestedNext = new URLSearchParams(window.location.search).get("next") || "/";
+ const safeNext = ALLOWED_NEXT_PATHS.has(requestedNext) ? requestedNext : "/";
+ window.location.assign(safeNext);
});