From 51c16209a0d4568450048af46e63541e0bc4b607 Mon Sep 17 00:00:00 2001 From: laoyang Date: Wed, 28 Oct 2026 17:45:19 +0800 Subject: [PATCH] =?UTF-8?q?4.1.1=20=E4=BF=AE=E8=AE=BE=E7=BD=AE=E9=A1=B5?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=E6=97=A0=E6=B3=95=E6=96=B0=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E6=89=93=E5=BC=80=EF=BC=88target=20=E8=A2=AB=20wp=5Fkses=20?= =?UTF-8?q?=E5=89=A5=E6=8E=89=EF=BC=89=20#33?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 用户反馈:设置页「数据导出服务」那个链接点下去在本页跳走了, 把正在改的设置页顶掉。 根因不是链接写错 —— 源码里 target="_blank" 一直在。是框架渲染 desc 时 走 wp_kses($explain_value, $allowedtags) (inc/options-framework/includes/class-options-interface.php:210/315), 而 WordPress 全局 $allowedtags['a'] 只有 href + title,target 和 rel 被静默剥掉。实测: 输入 数据导出服务 输出 数据导出服务 ← target/rel 消失 修法:在 kratos_options() 开头给 $allowedtags['a'] 补上 target / rel。 只放宽这两个属性,不放宽别的。时机是对的 —— _optionsframework_options() 在第 47 行就调 kratos_options(),早于所有 wp_kses 调用。 影响的不止这一个链接:robots.txt、设置-阅读、两个翻译 API 的链接 全都是同样情况,一并修好(共 5 处)。 线上真实环境验证: ALLOWED_BEFORE=href,title ALLOWED_AFTER=href,title,target,rel HAS_TARGET=YES 版本号 4.1.0 → 4.1.1:同一版本号重发 PUC 认不出(它用 version_compare 判严格大于),已装 4.1.0 的站点永远拿不到这次修复。readme 按用户确认 **并入现有 V4.1.0 节**,不新增一节(节数仍 57)。 补的判据(都做了注入反证): - _mkzip410.py 11c 段 5 条:白名单补了 target/rel、补的位置在 kratos_options() 内、「数据导出服务」链接带 target、没拿 window.open 绕过 - _mkzip410_falsify.py 17/18 组:删白名单必须变红,18/18 抓到 - _readme410.py 改造成替换模式 + 反证(不换首节必须红,42/0) 顺带修两个已过期的地方: - _mkzip410_falsify.py 的「版本号没改」注入锚点写死 "Version: 4.1.0", 升 4.1.1 后锚点未命中、反证报"没抓到"(其实是注入脚本自己过期) ⇒ 改成动态读当前版本号 - _publish410.sh 的 readme 首节判据要求 == 本版号,但 4.1.1 并入 V4.1.0 节 ⇒ 改成「首节是 4.1.x」+「本版修复说明真在里面」两头都验 线上已发布:md5 bd12b67f2c4ca5bec5053a02e49f2fe6 PUC 实测 HAS_UPDATE=YES(已装 4.1.0 → 新 4.1.1) --- inc/theme-options.php | 14 ++++++++++++++ style.css | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/inc/theme-options.php b/inc/theme-options.php index 4d333a2..e827589 100644 --- a/inc/theme-options.php +++ b/inc/theme-options.php @@ -139,6 +139,20 @@ if (!function_exists('yang_opt_default_custom_css')) { function kratos_options() { + /* 🔴 让 desc 里的链接能新窗口打开。 + 框架渲染 desc 时走 wp_kses($explain_value, $allowedtags) + (inc/options-framework/includes/class-options-interface.php:210/315), + 而 WordPress 的全局 $allowedtags['a'] 只有 href + title —— + **target / rel 会被静默剥掉**,代码里写着 target="_blank" 也不生效。 + 实测:wp_kses 输出里 target 消失,页面点链接在本页跳走。 + 在构建选项数组时补齐白名单(只补这两个属性,不放宽别的)。 */ + global $allowedtags; + if (!isset($allowedtags['a']) || !is_array($allowedtags['a'])) { + $allowedtags['a'] = array(); + } + $allowedtags['a']['target'] = true; + $allowedtags['a']['rel'] = true; + $sitename = get_bloginfo('name'); $imagepath = ASSET_PATH . '/assets/img/options/'; diff --git a/style.css b/style.css index 939b5ac..4d2ff57 100644 --- a/style.css +++ b/style.css @@ -1,7 +1,7 @@ /* Theme Name: Kratos_Yang Text Domain: kratos_Yang -Version: 4.1.0 +Version: 4.1.1 Requires PHP: 7.0 Description: 这是一个Kratos主题的分支版本,用来增加一些定制化功能。 Tags: 博客, 双栏, 响应式, 自定义背景, 自定义颜色, 自定义图标, 自定义菜单, 特色图像, 收录优化, 邮件中心, 主题选项, 小工具, 文章置顶, 无障碍友好