Skip to content

fix: position/filter 样式统计只在标签内匹配,修正英文正文子串误报 - #19

Merged
leether merged 1 commit into
mainfrom
fix/position-filter-css-false-positive
Nov 25, 2026
Merged

leether merged 1 commit into
mainfrom
fix/position-filter-css-false-positive

Conversation

@leether

@leether leether commented Nov 25, 2026

Copy link
Copy Markdown
Owner

问题

harness/preflight.mjs(本地推送前检查)和 scripts/create_wechat_draft.mjs(relay 上的推送后回检)都用裸字符串匹配统计 position: / filter:。正文里的英文单词子串会被数成 CSS 声明,例如参考文献标题 DICER1-related tumor predisposition: identification… 含子串 position:。

现场表现(2026-11-25):本地 preflight 报 html_compliance 失败并阻断推送,--auto-fix 无法修复;relay 回检写出 position: 1 ❌,而 style 内的 position 样式数实际为 0。

改动

  • 两处改用 countCssDeclarations(html, property),只在标签内部统计 CSS 声明(属性名前必须是行首、分号、引号或空白)。两份实现逐字相同,因为 relay 上运行的那份不能 import harness/。
  • 新增 harness/test-css-declaration-count.mjs:同一组用例跑两份实现并要求结果一致,另有本地 preflight 与推送后回检各一条端到端用例;已接入 npm run check。此前这两段匹配没有任何测试覆盖。
  • CHANGELOG 记一条。

验证

  • npm run check 全过,privacy-check.sh --full 通过。
  • 拿已推送的 25 个文章版本 HTML 新旧对比:只有触发误报的那一篇由 1 变 0,其余 24 个都是 0;没有发现旧逻辑漏掉的真实违规。
  • scripts/create_wechat_draft.mjs 的这份改动已通过 sync_relay_scripts.mjs --apply 部署到 relay(备份 create_wechat_draft.mjs.bak-20261125-063413),并在 relay 上直接调用 analyzeDraftContent 确认:参考文献标题数出 0,真实违规数出 1。

行为变化

  • 冒号前带空格的写法(position :absolute)旧逻辑漏判,新逻辑会计入。
  • 属性值里恰好以 position: 开头的文本(如 title="position: …")会被计入,方向保守。

preflight 与推送后回检都用裸字符串匹配统计 position:/filter:,
参考文献标题里的 "predisposition:" 被数成 1 处 position 样式:
本地 preflight 阻断且 --auto-fix 修不了,relay 回检写出 position: 1。

- harness/preflight.mjs、scripts/create_wechat_draft.mjs:改为只在标签内部统计 CSS 声明
- 新增 harness/test-css-declaration-count.mjs,同一组用例钉住两份实现,并接入 npm run check
- 25 个已推送版本回归:只有触发误报的那一篇结论由 1 变 0,其余不变
@leether
leether merged commit 99ffab5 into main Nov 25, 2026
2 checks passed
@leether
leether deleted the fix/position-filter-css-false-positive branch November 25, 2026 07:26
leether added a commit that referenced this pull request Nov 25, 2026
PR #19 新增的 test-css-declaration-count.mjs 只接入了 npm run check,
Lint workflow 的测试列表是写死的,CI 并不会跑到它。

- Run generated check tests 增加该测试
- push / pull_request 的 paths 增加 .github/workflows/lint.yml:
  否则只改 workflow 时 CI 不会运行,这次改动也无法在合并前被验证
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant