Skip to content

Commit 4000a45

Browse files
committed
Add invalid links test
1 parent 7a79f1e commit 4000a45

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/cypress/e2e/defaultFiltering.cy.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,27 @@ describe('Default HTML filtering', () => {
5454
expect(value).to.contain('title');
5555
});
5656
});
57+
58+
it('rejects invalid protocol links', () => {
59+
const text = '<p>This is an <a href="javascript://%0aalert(document.location)">xss test</a></p>';
60+
modifyContent(path, text);
61+
getContent(path).then(result => {
62+
const value = result.data.jcr.nodeByPath.property.value;
63+
expect(value).to.contain('<p>');
64+
expect(value).to.not.contain('<a');
65+
expect(value).to.not.contain('href');
66+
});
67+
});
68+
69+
it('rejects invalid href links', () => {
70+
const text = '<p>This is an <a href="#javascript:alert(\'hello\')" target="_blank">xss test</a></p>';
71+
modifyContent(path, text);
72+
getContent(path).then(result => {
73+
const value = result.data.jcr.nodeByPath.property.value;
74+
expect(value).to.contain('<p>');
75+
expect(value).to.contain('<a');
76+
expect(value).to.not.contain('href');
77+
expect(value).to.contain('target');
78+
});
79+
});
5780
});

0 commit comments

Comments
 (0)