mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-25 15:15:23 +03:00
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:
1 parent
9b655473bc
commit
3872432a07
4 files changed
+13
-2
No files matched your search
@@ -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(`[
|
||||
|
||||
Reference in new issue
Block a user