diff --git a/src/components/studio/views/export-helpers.test.ts b/src/components/studio/views/export-helpers.test.ts index 819784da..9f20f622 100644 --- a/src/components/studio/views/export-helpers.test.ts +++ b/src/components/studio/views/export-helpers.test.ts @@ -160,6 +160,22 @@ describe('buildHtmlExport', () => { expect(html).toContain('<script>') }) + it('escapes HTML and attribute breakout in entity type and claim verification', () => { + const maliciousEntity: Entity = { + ...SAMPLE_ENTITIES[0], + type: 'concept">' as Entity['type'], + } + const maliciousClaim: Claim = { + ...SAMPLE_CLAIMS[0], + verification: 'verified">' as Claim['verification'], + } + const html = buildHtmlExport([maliciousEntity], [maliciousClaim]) + expect(html).not.toContain('') + expect(html).not.toContain('') + expect(html).toContain('"><script>alert("xss-type")</script>') + expect(html).toContain('"><script>alert("xss-claim")</script>') + }) + it('preserves Markdown angle brackets in entity content', () => { const md: Entity[] = [{ ...SAMPLE_ENTITIES[0], diff --git a/src/components/studio/views/export-helpers.ts b/src/components/studio/views/export-helpers.ts index d26a04e7..86c30db2 100644 --- a/src/components/studio/views/export-helpers.ts +++ b/src/components/studio/views/export-helpers.ts @@ -76,7 +76,9 @@ export const buildHtmlExport = (entities: Entity[], claims: Claim[]): string => ? `