fix: respect save path changes and localize X media - #6
Open
aiirux-opc wants to merge 1 commit into
Open
aiirux-opc wants to merge 1 commit into
aiirux-opc wants to merge 1 commit into
Conversation
Scope duplicate detection to files in the currently configured save directories so captures are written after the primary destination changes. Allow trusted X media hosts to use proxy Fake-IP DNS results while preserving private-network and redirect validation, and support Bun's all-address lookup callback contract. Add regression coverage for save-path changes, Fake-IP boundaries, pinned DNS callbacks, and localized X image references.
This branch has not been deployed
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.
中文说明
变更摘要
本 PR 修复两个彼此独立、但都会表现为“设置已保存却没有生效”的问题:
198.18.0.0/15,图片下载在发出 HTTP 请求前就被 SSRF 防护拒绝;同时补齐了 Bun 1.3.13 对 DNS lookupall: true回调形式的兼容。问题根因
保存目录切换
duplicate_policy=skip原先只检查最新修订记录中的文件是否仍然存在,没有检查这些文件是否位于当前配置的save_paths。因此,即使用户已经切换主要保存目录,只要旧目录文件还在,保存流程就会直接返回skipped。X 图片本地化
代理软件可将
pbs.twimg.com、video.twimg.com等域名解析到基准测试网段198.18.0.0/15。该网段默认被视为非公网地址,原有安全下载逻辑会在连接前拒绝它。通过应用内置 Bun 1.3.13 做真实网络验证时还发现,HTTPS 客户端可能以
all: true调用自定义lookup。原实现始终通过单地址回调返回结果,导致 Bun 报出results.sort is not a function。实现方案
保存去重
save_path完全匹配”的索引文件视为有效目标。skip策略才返回skipped。update和always_new策略保持原有语义。安全下载与 Fake-IP
pbs.twimg.com和video.twimg.com。198.18.0.0/15。all: true数组回调,兼容 Node.js 与应用内置 Bun。行为变化
lookup(..., { all: true })文件变更
app/core/save.tsapp/core/safe-download.tsapp/tests/save-index.test.tsapp/tests/safe-download.test.tsapp/tests/api.test.ts验证结果
npm run checknpm run smoke:mac/ping、/save、/status、/log和/open冒烟测试通过。/Applications/X2MD.app内置 Bun 1.3.13 进行真实下载:pbs.twimg.com在测试网络中解析为198.18.0.52。/config -> /save链路验证:outcome=saved。media.completed=1、media.failed=0。兼容性与风险
English Description
Summary
This PR fixes two independent issues that both made saved settings appear ineffective:
198.18.0.0/15. The download was rejected by SSRF protection before any HTTP request was made. This PR also fixes the DNS lookup callback contract used by Bun 1.3.13 whenall: trueis requested.Root Causes
Save path changes
For
duplicate_policy=skip, the save pipeline previously checked only whether every file in the latest indexed revision still existed. It did not verify that those files belonged to the currently configuredsave_paths. A file left in the previous directory therefore caused an immediateskippedresult after the destination changed.X image localization
Some proxy configurations resolve
pbs.twimg.comandvideo.twimg.comto the benchmarking range198.18.0.0/15. The existing downloader correctly treated that range as non-public, but had no narrowly scoped way to distinguish a trusted platform media host using proxy Fake-IP DNS from an arbitrary untrusted host.Real-network testing with the Bun 1.3.13 bundled in the macOS app also showed that the HTTPS client may invoke a custom DNS
lookupwithall: true. The previous callback always returned one address instead of an address array, producingresults.sort is not a function.Implementation
Save deduplication
skippolicy returnsskippedonly when every current save path is already covered.updateandalways_newsemantics remain unchanged.Safe download and Fake-IP support
pbs.twimg.comandvideo.twimg.com.198.18.0.0/15.all: truearray callbacks for Node.js and the bundled Bun runtime.Behavior Changes
lookup(..., { all: true })Files Changed
app/core/save.tsapp/core/safe-download.tsapp/tests/save-index.test.tsapp/tests/safe-download.test.tsapp/tests/api.test.tsValidation
npm run checknpm run smoke:mac/ping,/save,/status,/log, and/openpassed./Applications/X2MD.app:pbs.twimg.comresolved to198.18.0.52in the test environment./config -> /saveflow:outcome=saved.media.completed=1,media.failed=0.Compatibility and Risk