mirror of
https://github.com/affaan-m/ECC.git
synced 2026-11-17 13:32:18 +00:00
fix(hooks): drop line continuations before checking text after a commit here-document
In double quotes Bash drops a backslash-newline before it expands anything, so a tail of `$\<newline>HOME` after the substitution's `)` is `$HOME` and expands. The expansion check read the tail with the continuation still in it and saw an escaped newline, so the hook validated `fix: a$HOME` with no warning. Continuations are now dropped first, while other escapes stay for the check: `\$\<newline>HOME` is still the literal `$HOME`.
This commit is contained in:
2 files changed
+14
-1
No files matched your search
@@ -244,7 +244,10 @@ function readHeredocMessage(value, heredoc) {
|
||||
} };
|
||||
}
|
||||
const after = /^[ \t\r\n]*\)((?:\\[\s\S]|[^"\\])*)"/.exec(value.slice(heredoc.end));
|
||||
if (!after || hasHeredocExpansion(after[1])) {
|
||||
// In double quotes Bash drops a backslash-newline before it expands anything, so
|
||||
// `$\<newline>HOME` is `$HOME`; other escapes stay for the expansion check to skip.
|
||||
const continued = after && after[1].replace(/\\([\s\S])/g, (escape, next) => (next === '\n' ? '' : escape));
|
||||
if (!after || hasHeredocExpansion(continued)) {
|
||||
return { issue: {
|
||||
type: 'unverifiable',
|
||||
message: 'Cannot validate a commit message that adds commands or expansions to its here-document',
|
||||
|
||||
Reference in new issue
Block a user