fix(hooks): read NUL-ended delimiters, Bash blanks before #, and long bodies

Bash ends a decoded $'...' string at its first NUL, so `cat <<$'EOF\0X'`
ends at the line EOF, but the splitter looked for EOF\0X and swallowed
the commands after the body. A carriage return or a no-break space is
not a blank to Bash, so `echo foo\r# && npm run dev` runs the dev
server, but the splitter read the # as a comment. And spreading a long
substitution's segments into push() threw RangeError, which the hook's
catch turned into an allow. Truncate the decoded part at the NUL, use
Bash's blanks for word starts, and append the segments one at a time.
This commit is contained in:
L4XB committed 2026-11-05 13:07:21 +01:00
1 parent 94d2c659ba
commit 30eb570117
4 files changed
+35 -4

No files matched your search

+6 -2
View File
@@ -204,8 +204,12 @@ function collectCheckSegments(cmd) {
for (const body of [...extractCommandSubstitutions(current), ...extractSubshellGroups(current)]) {
const bodySegments = splitShellSegments(body);
segments.push(...bodySegments);
queue.push(body, ...bodySegments);
// One at a time: spreading a long command's segments into push() exceeds the argument limit.
queue.push(body);
for (const segment of bodySegments) {
segments.push(segment);
queue.push(segment);
}
}
}