From 7e95f282bce4125978e1b07709ae39e5243133e8 Mon Sep 17 00:00:00 2001 From: ypsdf1 Date: Fri, 20 Nov 2026 10:44:39 +0800 Subject: [PATCH] =?UTF-8?q?125=E7=BB=AD15l-9=EF=BC=9A=E4=BF=AEesc=E6=9C=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89(admin=E6=94=B9escAdmHtml/player=E6=94=B9esca?= =?UTF-8?q?peHtml)+=E6=88=90=E4=B9=A6=E8=AF=AD=E4=B9=89=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin.php | 10 +++++----- player.php | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/admin.php b/admin.php index 1ebb00a..10168f2 100644 --- a/admin.php +++ b/admin.php @@ -4491,7 +4491,7 @@ async function loadRules(el) { }); const data = await res.json(); if (!data.success || !data.data) { - el.innerHTML = '
❌ 加载失败:' + esc(data.message || '未知错误') + '
'; + el.innerHTML = '
❌ 加载失败:' + escAdmHtml(data.message || '未知错误') + '
'; return; } const d = data.data; @@ -4523,8 +4523,8 @@ async function loadRules(el) { // 协议元信息 html += '

当前协议

'; - html += `

协议标题:${esc(d.title || '(无)')}
`; - html += `版本指纹:${esc(d.fingerprint || '')} | 共 ${d.line_count || 0} 行

`; + html += `

协议标题:${escAdmHtml(d.title || '(无)')}
`; + html += `版本指纹:${escAdmHtml(d.fingerprint || '')} | 共 ${d.line_count || 0} 行

`; html += `

玩家端可通过登录页「查看协议原文」或 /rules 阅读正文;后台此处仅监控签署进度。

`; html += '
'; @@ -4540,7 +4540,7 @@ async function loadRules(el) { const verBadge = r.current_version ? '✔ 当前版本' : '⚠ 旧版本(协议已更新,需重签)'; - html += `${esc(r.player)}` + html += `${escAdmHtml(r.player)}` + `${when}` + `${verBadge}`; } @@ -4550,7 +4550,7 @@ async function loadRules(el) { el.innerHTML = html; } catch (e) { - el.innerHTML = '
加载失败:' + esc(e.message) + '
'; + el.innerHTML = '
加载失败:' + escAdmHtml(e.message) + '
'; } } diff --git a/player.php b/player.php index 3758f0a..9caf887 100644 --- a/player.php +++ b/player.php @@ -1305,13 +1305,13 @@ if ($currentVersion !== $BUILD_VERSION) { // 渲染:用 原文 + 简单 markdown 转 html(标题/列表/加粗),不引入外部依赖 el.innerHTML = `
-

📜 ${esc(d.title || '服务器用户协议')}

+

📜 ${escapeHtml(d.title || '服务器用户协议')}

${renderMarkdownLite(d.content)}
-

协议版本指纹:${esc(d.fingerprint || '')} | 共 ${d.line_count || 0} 行

+

协议版本指纹:${escapeHtml(d.fingerprint || '')} | 共 ${d.line_count || 0} 行

`; } @@ -1334,7 +1334,7 @@ if ($currentVersion !== $BUILD_VERSION) { const lvl = s.match(/^#+/)[0].length; const txt = s.replace(/^#+\s*/, ''); const sz = Math.max(15, 22 - lvl); - html += `
${esc(txt)}
`; + html += `
${escapeHtml(txt)}
`; continue; } // 无序列表 @@ -1361,7 +1361,7 @@ if ($currentVersion !== $BUILD_VERSION) { // 行内 markdown:加粗/斜体/代码/链接 function inlineMd(s) { - let t = esc(s); + let t = escapeHtml(s); t = t.replace(/`([^`]*)`/g, '$1'); t = t.replace(/(\*\*|__)(.+?)\1/g, '$2'); t = t.replace(/(^|[^*])(\*)([^*]+)\*(?!\*)/g, '$1$3');