fix(ui): block active HTML in assistant markdown
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user