Fix escapeHtml → esc, flag self-loop subpaths with 🔄

Self-loops (likely prefix collisions) shown at 60% opacity with amber
frequency bar and 🔄 icon with tooltip explaining the collision.
This commit is contained in:
you
2026-03-19 01:20:23 +00:00
parent 66859842c8
commit e9ec3bb16a
2 changed files with 9 additions and 3 deletions
+5 -3
View File
@@ -783,12 +783,14 @@
</tr></thead><tbody>
${data.subpaths.map((s, i) => {
const barW = Math.max(2, Math.round(s.count / maxCount * 100));
return `<tr>
const hops = s.path.split(' → ');
const hasSelfLoop = hops.some((h, j) => j > 0 && h === hops[j - 1]);
return `<tr${hasSelfLoop ? ' class="subpath-selfloop"' : ''}>
<td>${i + 1}</td>
<td class="mono" style="white-space:nowrap">${escapeHtml(s.path)}</td>
<td class="mono" style="white-space:nowrap">${esc(s.path)}${hasSelfLoop ? ' <span title="Contains self-loop — likely 1-byte prefix collision" style="cursor:help">🔄</span>' : ''}</td>
<td>${s.count.toLocaleString()}</td>
<td>${s.pct}%</td>
<td><div style="background:var(--accent,#3b82f6);height:14px;border-radius:3px;width:${barW}%;opacity:0.7"></div></td>
<td><div style="background:${hasSelfLoop ? '#f59e0b' : 'var(--accent,#3b82f6)'};height:14px;border-radius:3px;width:${barW}%;opacity:0.7"></div></td>
</tr>`;
}).join('')}
</tbody></table>`;
+4
View File
@@ -1146,3 +1146,7 @@ button.ch-item.ch-item-encrypted .ch-badge { filter: grayscale(0.6); }
/* Ambiguous hop indicator */
.hop-ambiguous { border-bottom: 1px dashed #f59e0b; }
.hop-warn { font-size: 0.7em; margin-left: 2px; vertical-align: super; }
/* Self-loop subpath rows */
.subpath-selfloop { opacity: 0.6; }
.subpath-selfloop td:first-child::after { content: ''; }