mirror of
https://github.com/affaan-m/ECC.git
synced 2026-11-17 13:32:18 +00:00
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:
4 files changed
+35
-4
No files matched your search
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user