fix(markdown): escape backslashes in generated table cells

Pipes were escaped but backslashes were not, so a cell ending in `\` turned
the added `\|` into `\\|` and the pipe split the cell. The object-array
Markdown export also left newlines in cells, which broke the row; they now
become `<br>` like in the Markdown table generator.

Fixes CodeQL js/incomplete-sanitization alerts in the Markdown table
generator and the object-array export.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Sebastian DanielssonandClaude Opus 5.5 authored and sharevb committed 2026-10-03 21:11:50 +02:00
1 parent 9b655473bc
commit 3872432a07
4 files changed
+13 -2

No files matched your search

+5
View File
@@ -52,6 +52,11 @@ INSERT INTO users (id, name, age) VALUES (2, 'Bob', 30);`);
expect(result).toContain('| 2 | Bob | 30 |');
});
it('should escape Markdown table cells', () => {
const result = objectArrayToData([{ path: 'C:\\dir\\', note: 'a|`b`\nc' }], 'markdown');
expect(result).toContain('| C:\\\\dir\\\\ | a\\|\\`b\\`<br>c |');
});
it('should export nested JSON format correctly', () => {
const result = objectArrayToData(sampleNestedData, 'json', { tableName, nestify: true });
expect(result).toBe(`[