fix(approval): a trailer with a blank or padded name is refused

Review finding 8420915b.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kjell Tore Guttormsen 2026-10-13 14:40:10 +02:00
commit 1621352e67
Signed by: ktg
SSH key fingerprint: SHA256:JakMjO6FTBBzN0Bhfj9saOoEjaFxlSdYuZQQpM/lF9Q
2 changed files with 28 additions and 2 deletions

View file

@ -38,7 +38,10 @@ import { isMain } from './is-main.mjs';
export const ARTIFACT_STORES = Object.freeze(['git', 'local']);
const DEFAULT_MESSAGE = 'docs(voyage): record approval';
// One `Co-Authored-By:` line; `{`/`}` are refused so an unfilled `{model}` fails.
const TRAILER_RE = /^Co-Authored-By: [^<>{}\n]+ <[^\s<>@]+@[^\s<>]+>$/;
// The name starts and ends with a non-space, and trailerProblem refuses two
// spaces in a row, so an empty `{model}` ("Claude" + two spaces), a blank name
// and a padded one fail too (review 8420915b).
const TRAILER_RE = /^Co-Authored-By: [^\s<>{}](?:[^<>{}\n]*[^\s<>{}])? <[^\s<>@]+@[^\s<>]+>$/;
/** @returns {string|null} why `trailer` is refused, or null when it is valid */
function trailerProblem(trailer) {
@ -47,7 +50,7 @@ function trailerProblem(trailer) {
}
if (/[\r\n]/.test(trailer)) return '--trailer must be one line — nothing committed';
if (trailer.includes('Claude-Session:')) return '--trailer must not hold a Claude-Session: line — nothing committed';
if (!TRAILER_RE.test(trailer)) {
if (!TRAILER_RE.test(trailer) || trailer.includes(' ')) {
return `--trailer must read "Co-Authored-By: <name> <<email>>" with every placeholder filled; got "${trailer}" — nothing committed`;
}
return null;