diff --git a/ui/desktop/src/utils/htmlSecurity.test.ts b/ui/desktop/src/utils/htmlSecurity.test.ts index a13eb74a0..b7702d1f9 100644 --- a/ui/desktop/src/utils/htmlSecurity.test.ts +++ b/ui/desktop/src/utils/htmlSecurity.test.ts @@ -1,4 +1,5 @@ import { describe, it, expect } from 'vitest'; +import { performance } from 'node:perf_hooks'; import { containsHTML, wrapHTMLInCodeBlock } from '../utils/htmlSecurity'; describe('HTML Security Detection', () => { @@ -93,6 +94,15 @@ describe('HTML Security Detection', () => { expect(containsHTML('<>')).toBe(false); expect(containsHTML('< div >')).toBe(false); }); + + it('rejects unterminated comment prefixes without blocking the renderer', () => { + const maliciousContent = '/; - const hasComments = commentRegex.test(withoutCodeBlocks); + const commentStart = withoutCodeBlocks.indexOf('', commentStart + 4) !== -1; // Only detect potentially dangerous HTML tags that could execute or affect layout const dangerousHTMLRegex =