🐛 过滤 Chromium 不支持的 @match scheme - #1772
Open
cyfung1031 wants to merge 9 commits into
Open
cyfung1031 wants to merge 9 commits into
cyfung1031 wants to merge 9 commits into
Conversation
cyfung1031
marked this pull request as ready for review
September 22, 2026 19:38
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist / 检查清单
背景
#1771 的 RED 用例确认:ScriptCat 会把
notsupported://*/*与有效的https/http一起放进 Chromiumchrome.userScripts的 match-pattern 数组,单个不受支持的 scheme 因而使整条 userscript 注册失败。根因不是 MV3 本身,而是 ScriptCat 在进入浏览器原生 match-pattern API 前没有做 Chromium scheme 约束。
本次改动
修复放在 ScriptCat → 浏览器 API 边界,不收窄 ScriptCat 自己的 URL matcher:
matches/excludeMatches只保留当前支持的*、http、https、file;Firefox 不套用 Chromium 白名单。CompiledResource的启动恢复路径统一经过同一过滤函数。这是本次的 Pareto 范围:覆盖会重新把坏 pattern 送入浏览器的高影响入口与升级缓存路径;编辑器诊断、注册状态 UX 和更广泛 matcher 重构不混入这个 bug-fix PR。
实现考虑
静态 scheme 过滤只解决已经确认的 Chromium API 契约;不把 Chromium 的集合强加给 Firefox,避免未经验证地缩窄 Firefox 现有行为。
同时没有通过失败后逐项试注册来“探测”坏 pattern:先在无副作用的 API 投影层过滤,注册流程保持单次、确定性。
建议审查重点
https/http/notsupported时最终RegisteredUserScript.matches只剩有效项。excludeMatches、全局 blacklist 和旧CompiledResource不会绕过同一 scheme 过滤。关联
Fixes #1771
验证
2f4d5edb5e8ce309abb7efe9e223e4c596e8e6de,GitHub Actions run35743071085明确失败于新增断言:实际结果多出notsupported://*/*。049576d1bdc2e61101382f529646060678c3a6de的完整 GitHub Actions run35774571203已通过。007533fffac2256cd1d850f58a162ead748847e1:GitHub Actions run35774779814完整通过(pnpm lint:ci、2 个 Vitest coverage shards + merge、4 个 Playwright E2E shards);License Compliance 也为 success。github.com,因此未伪称本地 pnpm 结果;可执行验证以 GitHub Actions 为准。