Skip to content

Commit 9e06c04

Browse files
committed
💄
1 parent 1188664 commit 9e06c04

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/package.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ export async function versionBump(options: IVersionBumpOptions): Promise<void> {
418418
}
419419
}
420420

421-
export function sanitizeCommitMessage(message: string): string | undefined {
421+
function sanitizeCommitMessage(message: string): string | undefined {
422422
// Allow alphanumeric, space, common punctuation, newline characters.
423423
// Specifically check for characters that might escape quotes or introduce shell commands.
424424
// Newlines are allowed, but backslashes (other than for newlines), backticks, and dollar signs are still checked.
@@ -433,12 +433,12 @@ export function sanitizeCommitMessage(message: string): string | undefined {
433433
}
434434

435435
// Make sure all backslashes are followed by 'n' to prevent shell injection
436-
sanitizedMessage.split('').reduce((positions: number[], char: string, index: number) => {
436+
for (let index = 0; index < sanitizedMessage.length; index++) {
437+
const char = sanitizedMessage[index];
437438
if (char === '\\' && sanitizedMessage[index + 1] !== 'n') {
438439
throw new Error('Commit message contains potentially dangerous characters after initial sanitization.');
439440
}
440-
return positions;
441-
}, []);
441+
}
442442

443443
if (sanitizedMessage.length === 0) {
444444
return undefined;

0 commit comments

Comments
 (0)