diff --git a/scripts/static/js/sidebar.js b/scripts/static/js/sidebar.js index 366700d71..24d98bd33 100644 --- a/scripts/static/js/sidebar.js +++ b/scripts/static/js/sidebar.js @@ -49,7 +49,7 @@ export function showSidebarContent(d, fromHover = false) { // Helper to render tab content function renderSidebarTabContent(tabName, d, children) { if (tabName === 'Code') { - return `
${d.code}`;
+ return `${escapeHtml(d.code)}`;
}
if (tabName === 'Prompts') {
// Prompt select logic
@@ -328,4 +328,15 @@ export function openInNewTab(event, d) {
export function setSidebarSticky(val) {
sidebarSticky = val;
+}
+
+// Helper to escape HTML so code can be shown verbatim inside
+function escapeHtml(str) {
+ if (str === undefined || str === null) return '';
+ return String(str)
+ .replace(/&/g, '&')
+ .replace(//g, '>')
+ .replace(/"/g, '"')
+ .replace(/'/g, ''');
}
\ No newline at end of file