Repository navigation
fix(validate): 清单文件按 UTF-8 解码,不是 UTF-8 就读不了 - #185
Merged
Merged
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.
plugin.json、package.json、miniapp.json这些清单,以前读的时候是宽松的:字节按 UTF-8 解,解不出来的部分换成 U+FFFD 就接着往下走。所以一份用 GBK 存下来的清单,在npm run check那里照样过。宿主不是这么读的。MiniMax Code 读清单用的解码器是 fatal 的,不是 UTF-8 直接报错
PLUGIN_TEXT_INVALID_UTF8,包根本不装。不是理论问题。拿一份带中文说明的 plugin.json 存成 GBK 试,在当前的 main 上:
npm run checkexit 0,全绿。宿主读同一个包:PLUGIN_TEXT_INVALID_UTF8 — .minimax-plugin/plugin.json is not valid UTF-8。改的是读清单那一处:先按字节读,再用
TextDecoder('utf-8', { fatal: true })解。解不出来就是解不出来,报is not valid UTF-8,跟宿主一个口径。清单坏的是编码不是格式,所以报的是「读不了」不是「格式不对」。有一处特意留着。解码器加了
ignoreBOM: true,因为默认的解码器会把 BOM 吃掉 —— 那样下面那条查 BOM 的规则就永远不触发。原来那条规则没动,package.test.mjs里管它的测试也没动,现在仍然报。docs/package-contract.md开头写的是「npm run checkenforces the same rules here」。这条以前没对上,现在对上了。文档里补了一节,写清哪些文件按文本读、读不了算哪种错。测试加了四条:plugin.json、package.json、miniapp.json 各自存成 GBK 都被拒,中文 UTF-8 的清单照旧过。前三条在未改的 main 上是红的 —— 那边读的是宽松解码,清单照样过。全量 100 条过。
零回归是量出来的。完整克隆上
node scripts/validate.mjs的输出与未改基线逐字节相同,md5 都是22e5461b67389f133403ca8c2b5490c0。没验证的部分说清楚。文档写的是「Verified against MiniMax Code 3.1.11」,本机只有 3.1.14,我只翻了 3.1.14 的源码,没翻旧版确认它当年也这样。
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.