Skip to content

Commit 41444ad

Browse files
OgeonX-Airoot
andauthored
fix(dashboard): escape rendered trace fields (#27)
Co-authored-by: root <root@Kimi.localdomain>
1 parent 091e1f6 commit 41444ad

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

dashboard/index.html

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,21 @@ <h1>Promptimprover Swarm Dashboard</h1>
3535
const tr = document.createElement('tr');
3636
const fmtTime = new Date(log.timestamp).toLocaleTimeString();
3737
const reason = log.reasoning_path && log.reasoning_path.length > 60 ? log.reasoning_path.slice(0,57) + '...' : log.reasoning_path;
38-
['time', 'span', 'persona', 'action', 'tokens', 'reasoning'].forEach((k, i) => {
39-
const td = document.createElement('td');
40-
const values = [fmtTime, log.span_id || 'N/A', log.persona || 'Unknown', log.action_type || 'Unknown', log.metrics?.total_tokens || 0, reason || ''];
41-
td.textContent = values[i];
42-
tr.appendChild(td);
43-
});
38+
const escapeHtml = (unsafe) => (unsafe || '').toString()
39+
.replace(/&/g, "&amp;")
40+
.replace(/</g, "&lt;")
41+
.replace(/>/g, "&gt;")
42+
.replace(/"/g, "&quot;")
43+
.replace(/'/g, "&#039;");
44+
45+
tr.innerHTML = `
46+
<td>${escapeHtml(fmtTime)}</td>
47+
<td>${escapeHtml(log.span_id || 'N/A')}</td>
48+
<td>${escapeHtml(log.persona || 'Unknown')}</td>
49+
<td>${escapeHtml(log.action_type || 'Unknown')}</td>
50+
<td>${escapeHtml(log.metrics?.total_tokens || 0)}</td>
51+
<td>${escapeHtml(reason || '')}</td>
52+
`;
4453
tbody.appendChild(tr);
4554
});
4655
}

0 commit comments

Comments
 (0)