目录选择器截断含「开」等字符的路径:dsh-host-directory-picker-native: native picker truncates paths containing chars with 0x00 low byte (e.g. 开 U+5F00) #2519
devwangrui
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Environment
Summary
readUtf16inpackages/host/directory-picker-native/src/win32-dialog-bindings.tsonly checks the LOW byte of each UTF-16 code unit for the NUL terminator. Any
character whose code point is a multiple of 256 (low byte 0x00) is mistaken for
the string terminator, truncating the selected path.
Reproduce
海康开放平台(contains 开 = U+5F00).workspace-invalid-path: cannot create a workspace at "D:\视频播放\海康":
ENOENT: no such file or directory, realpath 'D:\视频播放\海康'
The path is truncated at 开 (dropping 开放平台).
Root cause
packages/host/directory-picker-native/src/win32-dialog-bindings.ts:40This checks only
bytes[end](the low byte). A UTF-16LE NUL terminator is0x0000 (both bytes zero), but
开(U+5F00) encodes as00 5F, whose low byteis 0, so it is misread as the terminator.
Fix
Verification
All reactions