未认证访问登录后误进首页:302 /login 带 next=originalUrl,登录成功/token静默恢复/bfcache僵尸页踢回均按 next 回跳原页(仅认同源/路径,拦//与反斜杠防开放重定向);前端 core/files 的 401 跳登录同样带上当前页

This commit is contained in:
2026-09-26 10:13:45 +08:00
parent 6ff1646c14
commit 9892e48cbe
4 changed files with 25 additions and 8 deletions
+1 -1
View File
@@ -496,7 +496,7 @@
async function previewInFs(name) {
try {
const r = await fetch('/api/sessions/' + state.sessionId + '/files/download?path=' + encodeURIComponent(name));
if (r.status === 401) { location.href = '/login'; return; }
if (r.status === 401) { location.href = '/login?next=' + encodeURIComponent(location.pathname + location.search); return; }
if (!r.ok) { let msg = 'HTTP ' + r.status; try { msg = (await r.json()).error || msg; } catch (_) {} throw new Error(msg); }
if (/\.html?$/i.test(name)) {
const html = await r.text();