fix: escape workflow manifest values safely

This commit is contained in:
Dicky Moore 2025-12-08 21:54:13 +00:00
parent 3b4a47272b
commit e6ff8ed23f
1 changed files with 2 additions and 7 deletions

View File

@ -581,7 +581,7 @@ class ManifestGenerator {
*/ */
async writeWorkflowManifest(cfgDir) { async writeWorkflowManifest(cfgDir) {
const csvPath = path.join(cfgDir, 'workflow-manifest.csv'); const csvPath = path.join(cfgDir, 'workflow-manifest.csv');
const escapeCsv = (value) => `"${String(value ?? '').replace(/"/g, '""')}"`; const escapeCsv = (value) => `"${String(value ?? '').replaceAll('"', '""')}"`;
const parseCsvLine = (line) => { const parseCsvLine = (line) => {
const columns = line.match(/(".*?"|[^",\s]+)(?=\s*,|\s*$)/g) || []; const columns = line.match(/(".*?"|[^",\s]+)(?=\s*,|\s*$)/g) || [];
return columns.map((c) => c.replaceAll(/^"|"$/g, '')); return columns.map((c) => c.replaceAll(/^"|"$/g, ''));
@ -635,12 +635,7 @@ class ManifestGenerator {
// Write all workflows // Write all workflows
for (const [, value] of allWorkflows) { for (const [, value] of allWorkflows) {
const row = [ const row = [escapeCsv(value.name), escapeCsv(value.description), escapeCsv(value.module), escapeCsv(value.path)].join(',');
escapeCsv(value.name),
escapeCsv(value.description),
escapeCsv(value.module),
escapeCsv(value.path),
].join(',');
csv += row + '\n'; csv += row + '\n';
} }