Skip to content

Commit a95a17c

Browse files
committed
test: link sanitization tests
1 parent 0263e54 commit a95a17c

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

src/web/__tests__/mentionSanitization.test.ts renamed to src/web/__tests__/sanitization.test.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ describe('checkMentionAttributes', () => {
8282
});
8383
});
8484

85-
describe('sanitizeHtml', () => {
85+
describe('sanitizeHtmlMention', () => {
8686
it('keeps <mention> tags with text/indicator/data-* attributes', () => {
8787
const out = sanitizeHtml(
8888
'<mention text="Joe" indicator="@" data-user-id="42">@Joe</mention>'
@@ -98,3 +98,16 @@ describe('sanitizeHtml', () => {
9898
).not.toContain('onclick');
9999
});
100100
});
101+
102+
describe('sanitizeLinkAttributes', () => {
103+
it('strips javascript: URLs from links', () => {
104+
const out = sanitizeHtml('<a href="javascript:alert(1)">x</a>');
105+
// eslint-disable-next-line no-script-url
106+
expect(out).not.toContain('javascript:');
107+
});
108+
109+
it('strips unknown protocol URLs from links', () => {
110+
const out = sanitizeHtml('<a href="custom://link">x</a>');
111+
expect(out).not.toContain('custom');
112+
});
113+
});

0 commit comments

Comments
 (0)