Repository navigation
Conversation
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 / 检查清单
Description / 描述
Close #1635
问题:#1506 让 native 模式的
GM_download走verifyXhrConnect(@connect / 黑名单 / 站点访问校验)。data: URI 没有主机名,new URL("data:...").hostname为空,于是落到最后的cors确认分支,弹出一个「请求域名」为空的跨域权限框(issue 截图即此情况)。data: URI 内容自带、不发起任何网络请求,没有可校验的对象,这个弹窗没有意义;如果脚本声明了@connect,按同样的路径还会落到软确认弹窗。修复:在
GM_download的confirm中,与非 native 模式一样,对data:scheme 直接放行(src/app/service/service_worker/gm_api/gm_api.ts)。按 issue 讨论中的结论,不额外引入@connect特殊规则。实现考虑
data:。file:等其他非 http(s) scheme 仍走原校验(读本地文件属于敏感访问);blob:在内容侧本来就走 browser 模式,不经过此校验。/^\s*data:/i判断,没有用URL.parse:URL.parse需要 Chrome/Firefox 126+,仓库里没有用过,也没有声明最低浏览器版本。GM_download;GM_xmlhttpRequest请求 data: 的行为不在本 issue 内,没有改动。验证
基于
origin/main58309d5,head 079feda。native 下载 data: URI 不发起网络请求,无需 @connect 也直接放行 (#1635),修复前失败,返回permission: "cors", permissionValue: "",与截图一致;修复后通过。pnpm exec vitest run --no-coverage src/app/service/service_worker/gm_api/ src/app/service/content/gm_api/:11 个文件、151 个用例全部通过。pnpm run typecheck、prettier --check、改动文件的eslint:通过。saveAs: false方便无头运行,用e2e/session.mjs加载dist/ext,打开本地 http 页面):gm_api.ts换回origin/main版本后重新 build):打开confirm.html,标题「脚本正在试图访问跨域资源」,「请求域名」为空,「请求地址」为 data: URI,和 issue 截图一致;chrome.downloads.search为空,没有发起下载。[V1635] onload fired,下载状态为complete,全程没有打开确认页。前一轮验证中还检查过落盘内容为a,b,c\n1,2,3。