Replies: 2 comments
|
Verified against the rc.2 source — your diagnosis is exact. const bytes = Buffer.from(koffi.view(address, 32768))
let end = 0
while (end + 1 < bytes.length && bytes[end] !== 0) end += 2
return bytes.toString('utf16le', 0, end)1. You've hit the ~10th report of this truncation family. Same low-byte-NUL scan: #3188 = #3279 = #3291 (duplicates), #3442, #3419, #3505 (all confirmed), #3463 (candidate), plus today's #4624 (same mechanism, 2. But this function has a second, independent bug your patch does not fix — and it's a crash, not a truncation. 3. Combined fix — dual-byte terminator + grow-bounded view: function readUtf16(koffi: Koffi, address: unknown): string {
let size = 512 // start small: most paths are short
while (size <= 32768) { // cap preserves today's max-path behavior
const bytes = Buffer.from(koffi.view(address, size))
for (let end = 0; end + 1 < bytes.length; end += 2) {
if (bytes[end] === 0 && bytes[end + 1] === 0) { // real UTF-16 NUL
return bytes.toString('utf16le', 0, end)
}
}
if (size === 32768) return bytes.toString('utf16le', 0, size)
size *= 2 // no terminator: the allocation is bigger
}
return ''
}Two behaviors, one loop: it stops at the first true 4. Regression tests already exist to extend — |
|
Confirmed — and your example is the clearest of the three reports of this, because it names the property that actually matters.
That is the real rule: it is not "Chinese paths break", nor "mixed English and Chinese breaks". It is specifically a character whose low byte is zero — U+xx00 — which is why some Chinese directory names work perfectly and others truncate mid-name. Fix: while (end + 1 < bytes.length && bytes.readUInt16LE(end) !== 0) end += 2Same root cause as #4624 (U+4E00 |
Uh oh!
There was an error while loading. Please reload this page.
环境
0.1.1-rc.2(npm 全局安装@deepseek-ai/dsh)dsh web本机部署,浏览器访问 http://127.0.0.1:3080IFileDialog,由dsh-host-directory-picker-native的子进程驱动)复现步骤
%USERPROFILE%\Documents下新建文件夹软件开发C:\Users\15301\Documents\软件期望 / 实际
...\软件开发被接纳为工作区...\软件;由于该目录不存在,workspaces.create报错,工作区加不上根因
@deepseek-ai/dsh-host-directory-picker-native/lib/worker.cjs的readUtf16()在扫描 NUL 结尾的 UTF-16 缓冲区时,只检查每个码元的低字节是否为 0:「开」的码点是 U+5F00,UTF-16LE 内存字节为
00 5F——低字节恰好是 0x00,被误判为字符串结尾,路径即在此截断。凡是名字里含 U+xx00 形字符的目录都会触发(如 一 U+4E00、开 U+5F00)。macOS/Linux 后端走 stdout 文本(UTF-8),不受影响;此问题仅限 Windows 原生选择框。对同一份字节分别运行新旧算法的最小复现:
建议修复
终止符判断改为「连续两个字节均为 0」(真正的 UTF-16 NUL 终止符):
备注
已在本机按上述方式临时修补
worker.cjs并验证通过(选择框子进程每次点选时重新拉起,无需重启即可生效);注意 npm 升级 dsh 会覆盖该文件,希望官方在源码(win32-dialog-bindings.ts的同一处逻辑)中修复。All reactions