fix(build): 署名注入改走 Node 规范化 + for /f 直读文件
上一版用 PowerShell 管道读取:PS 5.1 的 Get-Content 默认按 ANSI 读,输出再经 cmd(chcp 65001) 解码一次,中文署名被转成乱码 —— 日志写着 injected,但 exe 里的 字节与预期不符(实测 sig_in_exe=False)。 改为 deploy/prepare-signature.mjs 读 UTF-8 并剥 BOM/空白,写出 signature.build.txt (gitignore),build.bat 用 for /f 直接读文件(不经过任何编码转换)。 另加一条 findstr 自检:注入后若 exe 里找不到署名就打印 [warn]。
This commit is contained in:
1 parent
13f1f03cd0
commit
e7948088df
3 files changed
+33
-3
No files matched your search
@@ -0,0 +1,26 @@
|
||||
// 把构建机本地署名规范化成一份纯文本,供 build.bat 用 for /f 直接读文件。
|
||||
//
|
||||
// 为什么不用 PowerShell 管道:PowerShell 5.1 的 Get-Content 默认按系统 ANSI 码页读,
|
||||
// 输出再经 cmd(chcp 65001)解码一次,中文会被转成乱码——曾导致日志写着
|
||||
// "internal signature injected",但 exe 里的字节和预期对不上。
|
||||
// 用 Node 读 UTF-8 再写回,同时剥掉可能的 BOM 与首尾空白,保证注入值稳定。
|
||||
import { existsSync, readFileSync, writeFileSync } from 'node:fs'
|
||||
import { dirname, join } from 'node:path'
|
||||
|
||||
const root = dirname(import.meta.dirname)
|
||||
const src = join(root, 'deploy', 'signature.local.txt')
|
||||
const dst = join(root, 'deploy', 'signature.build.txt')
|
||||
|
||||
if (!existsSync(src)) {
|
||||
console.log(' no internal signature file')
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
const first = readFileSync(src, 'utf8').replace(/^\uFEFF/, '').split(/\r?\n/, 1)[0].trim()
|
||||
if (first === '') {
|
||||
console.log(' internal signature file is empty')
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
writeFileSync(dst, first, 'utf8')
|
||||
console.log(' internal signature normalized')
|
||||
Reference in new issue
Block a user