Skip to content

Commit 0444bac

Browse files
jbernard077claude
andcommitted
fix(docs-codegen): escape backslashes before pipes in controls-table cells
Escaping only the pipe let an authored backslash combine with the inserted escape (or a following character) into an unintended sequence — CodeQL js/incomplete-string-escaping. Backslashes are now escaped first, so authored text round-trips faithfully into the markdown table. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 64ef083 commit 0444bac

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

scripts/generate-catalog-pages.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -792,9 +792,13 @@ interface ItemControl {
792792
drives: string;
793793
}
794794

795-
/** Pipe characters break table cells; everything user-authored passes through here. */
795+
/**
796+
* Pipes break table cells; everything user-authored passes through here.
797+
* Backslashes are escaped first so an authored `\` can never combine with the
798+
* inserted `\|` escapes (or a following character) into an unintended sequence.
799+
*/
796800
function tableCell(value: string): string {
797-
return value.replace(/\|/g, "\\|");
801+
return value.replace(/\\/g, "\\\\").replace(/\|/g, "\\|");
798802
}
799803

800804
/** The allowed inputs for one control, written the way a reader has to type them. */

0 commit comments

Comments
 (0)