@@ -1403,7 +1403,7 @@ function createTagCard(columnId, type, value, isExclude = false) {
card.innerHTML = `
`;
@@ -1448,22 +1448,22 @@ function renderCollections(data) {
if (!data.length) return '
- ${f['file_name']}
-
|
- # ${f['file_md5']}
- ${f['language_id']}
+ # ${escapeHtml(f['file_md5'])}
+ ${escapeHtml(f['language_id'])}
|
-
- ${batchUuid.length > 8 ? batchUuid.substring(0, 8) + '...' : batchUuid}
+ |
+ ${escapeHtml(batchUuid.length > 8 ? batchUuid.substring(0, 8) + '...' : batchUuid)}
|
@@ -1559,44 +1559,45 @@ function renderFunctions(data) {
const safeName = (name || '').replace(/'/g, "\\'");
const fInfo = formatSigComponent(namespace, returnType, name, parameters);
+ const renderedSig = `${fInfo.ret ? ` ${escapeHtml(fInfo.ret)} ` : ''}${fInfo.ns ? ` ${escapeHtml(fInfo.ns)}::` : ''}${escapeHtml(name)} (${fInfo.params.map(t => ` ${escapeHtml(t)}`).join(' , ')} )`;
const rowStyle = getRowTagColor(tags, user_tags);
return `
-
+
-
-
+
- ${fInfo.ret ? `${fInfo.ret} ` : ''}${fInfo.ns ? `${fInfo.ns}::` : ''}${name}(${fInfo.params.map(t => `${t}`).join(', ')})
+ onclick="showFunctionCodeById(${escapeAttr(jsString(funcId))}, ${escapeAttr(jsString(name))}, '', event)">
+ ${renderedSig}
- ±
+ onclick="addToDiff(${escapeAttr(jsString(funcId))}, ${escapeAttr(jsString(name))})" title="Add to Diff" style="padding:0 5px; font-size: 0.75rem; border-radius: 3px;"> ±
|
- @ ${entry} |
+ @ ${escapeHtml(entry)} |
${renderTagEditor('function', funcId, tags, user_tags)} |
${renderClusterCards(f['clusters'])} |
${featCount}
- 🔍
+ 🔍
|
- ${fileName} |
- # ${file_md5} |
+ ${escapeHtml(fileName)} |
+ # ${escapeHtml(file_md5)} |
${renderTagEditor('file', `${f.collection || 'main'}:file:${file_md5}`, f.file_tags || [], f.file_user_tags || [])} |
- ${language} |
+ ${escapeHtml(language)} |
${formatDate(f['entry_date'] || f['file_date'])} |
|
@@ -1614,7 +1615,7 @@ function renderGlobalFeatures(items) {
let pcodeHtml = `
- ${ctx.pcode_full || 'N/A'}
+ ${escapeHtml(ctx.pcode_full || 'N/A')}
`;
@@ -1637,14 +1638,14 @@ function renderGlobalFeatures(items) {
'keyword': 'tok-keyword', 'comment': 'tok-comment', 'string': 'tok-string', 'number': 'tok-number'
};
const cls = colorMap[t.type] || 'tok-default';
- cCodeHtml += ` ${t.text.replace(/&/g, '&').replace(/`;
+ onmousemove="moveCodePreview(event)">${escapeHtml(t.text)}`;
});
cCodeHtml += ` `;
}
@@ -1653,15 +1654,15 @@ function renderGlobalFeatures(items) {
|
${(p.score * 100).toFixed(1)}%
-
±
@@ -1722,44 +1724,44 @@ function renderTopCorrelations(items) {
|
-
-
+
- ${f1.ret ? `${f1.ret} ` : ''}${f1.ns ? `${f1.ns}::` : ''}${p.name1 || '---'}(${f1.params.map(t => `${t}`).join(', ')})
+ onclick="showFunctionCodeById(${escapeAttr(jsString(p.id1))}, ${escapeAttr(jsString(p.name1 || '---'))}, '', event)">
+ ${renderSig(f1, p.name1)}
- ±
+ onclick="addToDiff(${escapeAttr(jsString(p.id1))}, ${escapeAttr(jsString(p.name1 || '---'))})" title="Add to Diff" style="padding:0 5px; font-size: 0.75rem; margin-left: 4px; border-radius: 3px;">±
-
-
+
- ${f2.ret ? `${f2.ret} ` : ''}${f2.ns ? `${f2.ns}::` : ''}${p.name2 || '---'}(${f2.params.map(t => `${t}`).join(', ')})
+ onclick="showFunctionCodeById(${escapeAttr(jsString(p.id2))}, ${escapeAttr(jsString(p.name2 || '---'))}, '', event)">
+ ${renderSig(f2, p.name2)}
- ±
+ onclick="addToDiff(${escapeAttr(jsString(p.id2))}, ${escapeAttr(jsString(p.name2 || '---'))})" title="Add to Diff" style="padding:0 5px; font-size: 0.75rem; margin-left: 4px; border-radius: 3px;">±
|
- @ ${addr1}
- @ ${addr2}
+ @ ${escapeHtml(addr1)}
+ @ ${escapeHtml(addr2)}
|
@@ -1778,24 +1780,24 @@ function renderTopCorrelations(items) {
${p.meta1?.bsim_features_count || 0}
- 🔍
+ 🔍
${p.meta2?.bsim_features_count || 0}
- 🔍
+ 🔍
|
- ${p.meta1?.file_name || ''}
- ${p.meta2?.file_name || ''}
+ ${escapeHtml(p.meta1?.file_name || '')}
+ ${escapeHtml(p.meta2?.file_name || '')}
|
- # ${m1}
- # ${m2}
+ # ${escapeHtml(m1)}
+ # ${escapeHtml(m2)}
|
@@ -1806,8 +1808,8 @@ function renderTopCorrelations(items) {
|
- ${p.meta1?.language_id || '---'}
- ${p.meta2?.language_id || '---'}
+ ${escapeHtml(p.meta1?.language_id || '---')}
+ ${escapeHtml(p.meta2?.language_id || '---')}
|
@@ -1878,14 +1880,14 @@ function showFunctionCodeById(id, name, lineHash = '', e) {
function seeSimilarFromCode() {
const win = windowManager.activeWindow;
if (!win || !win.iframe || !win.iframe.src) return;
-
+
let url;
try {
url = new URL(win.iframe.contentWindow.location.href);
} catch(e) {
url = new URL(win.iframe.src, window.location.origin);
}
-
+
const id = url.searchParams.get('id');
if (!id) return;
@@ -2003,7 +2005,7 @@ function updateUIParams() {
localStorage.setItem('cohesionThreshold', UIParams.cohesionThreshold);
localStorage.setItem('colorByTag', UIParams.colorByTag);
localStorage.setItem('includeHeaders', UIParams.includeHeaders);
-
+
// Sync with sim-color-by-tag for tags.js compatibility
localStorage.setItem('sim-color-by-tag', UIParams.colorByTag);
@@ -2217,7 +2219,7 @@ async function populateCollectionDropdown() {
if (!res.ok) return;
const data = await res.json();
const collections = data.collections || (Array.isArray(data) ? data : []);
-
+
const list = document.getElementById('collection-flyout-list');
const trigger = document.getElementById('nav-collections');
const flyout = document.getElementById('collection-flyout');
@@ -2233,9 +2235,9 @@ async function populateCollectionDropdown() {
}
list.innerHTML = collections.map(c => `
-
+
- ${c.name}
+ ${escapeHtml(c.name)}
`).join('') || ' No collections found ';
@@ -2262,7 +2264,7 @@ async function populateCollectionDropdown() {
trigger.addEventListener('mouseleave', hide);
flyout.addEventListener('mouseenter', () => { if (hideTimeout) clearTimeout(hideTimeout); });
flyout.addEventListener('mouseleave', hide);
-
+
trigger.dataset.hasListener = "true";
}
} catch (e) {
@@ -2502,7 +2504,7 @@ window.showGraphContextMenu = function(e, type, data, isRefresh = false) {
// Generate HTML content based on type
let html = '';
-
+
if (type === 'node') {
const nodeId = data.id;
const nodeName = data.name;
@@ -2512,7 +2514,7 @@ window.showGraphContextMenu = function(e, type, data, isRefresh = false) {
const tags = latestNode.tags || [];
html += ``;
-
+
// Bookmark/Ignore/Tag actions
html += renderBookmarkIgnoreTagItems('function', nodeId, tags, userTags);
@@ -2543,17 +2545,17 @@ window.showGraphContextMenu = function(e, type, data, isRefresh = false) {
if (selectedSim) {
const simId = selectedSim.sid || `${selectedSim.id1}|${selectedSim.id2}|${selectedSim.algo}`;
// Fetch latest pair from graph all_pairs to get latest tags
- const latestPair = graph.all_pairs.find(p =>
- (p.id1 === selectedSim.id1 && p.id2 === selectedSim.id2) ||
+ const latestPair = graph.all_pairs.find(p =>
+ (p.id1 === selectedSim.id1 && p.id2 === selectedSim.id2) ||
(p.id1 === selectedSim.id2 && p.id2 === selectedSim.id1)
) || selectedSim;
-
+
const simUserTags = latestPair.user_tags || [];
const simTags = latestPair.tags || [];
const percentScore = (parseFloat(selectedSim.score) * 100).toFixed(1);
html += ``;
-
+
html += `
|