fix(ui): block active HTML in assistant markdown

This commit is contained in:
Bohdan Triapitsyn
2026-08-02 16:12:23 +03:00
parent 7afec99f80
commit b1ec34162e
6 changed files with 47 additions and 3 deletions
@@ -138,6 +138,11 @@ describe('classifyMention', () => {
expect(classifyMention('', classifier)).toBeNull();
});
test('HTML fragments do not classify as file references', () => {
expect(classifyMention('import</style>', classifier)).toBeNull();
expect(classifyMention('src/<style.css', classifier)).toBeNull();
});
test('an agent name wins over a file-looking name', () => {
const shadowed = {
knownAgentNames: new Set(['a.ts']),
@@ -152,4 +157,3 @@ describe('classifyMention', () => {
expect(looksLikeFilePath('plain', new Set(['plain']))).toBe(true);
});
});
@@ -116,6 +116,9 @@ export function classifyMention(
classifier: MentionClassifier,
): MentionKind | null {
if (!name) return null;
// HTML fragments are prompt text, never references. In particular, do not
// interpret CSS syntax such as `@import</style>` as a local file path.
if (name.includes('<') || name.includes('>')) return null;
if (classifier.knownAgentNames.has(name.toLowerCase())) return 'agent';
if (looksLikeFilePath(name, classifier.confirmedMentions)) return 'file';
return null;