Potential risk: .trim() removal in scan-project.mjs may mishandle paths with trailing spaces (commit b4d856d) #376
kapil971390
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.
-
Bug Report
Commit:
b4d856d— fix(scan-project): preserve non-ASCII path bytes viagit ls-files -zWhat was fixed
The PR correctly fixes silent file drops for non-ASCII paths (emoji, accented chars, CJK) by switching to
git ls-files -z(NUL-terminated output) instead of newline-separated output.Remaining risk
The fix removes
.trim()entirely alongside the delimiter change:This is correct for non-ASCII paths — but it also means file names with legitimate trailing spaces (e.g.
file .txt) are now preserved with their whitespace, whereas before they would have been silently trimmed.If any downstream consumer does a string equality check or file lookup against a path without accounting for trailing spaces, it will silently fail to match.
Steps to verify
Suggested safeguard
Replace the blanket
.trim()removal with a targeted empty-entry filter only:This keeps NUL-split behavior while making it explicit that only the trailing empty entry is dropped — not legitimate whitespace.
Beta Was this translation helpful? Give feedback.
All reactions