Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should allow audio tags with some attributes', () => {
const audio =
'<audio src="my/audio.ogg autoplay loop ' + 'controls muted"></audio>';
expect(defaultSanitizer.sanitize(audio)).to.equal(audio);
});
it('should allow harmless inline CSS', () => {
const div = '<div style="color:green;"></div>';
expect(defaultSanitizer.sanitize(div)).to.equal(div);
});
it('should strip link tags', () => {
const link = '';
expect(defaultSanitizer.sanitize(link)).to.equal('');
});
it("should strip 'widows' properties from inline CSS", () => {
const div = '<div style="widows: 2;"></div>';
expect(defaultSanitizer.sanitize(div)).to.equal('<div></div>');
});
it("should strip 'content' properties from inline CSS", () => {
const div = '<div style="color: green; content: attr(title)"></div>';
expect(defaultSanitizer.sanitize(div)).to.equal(
'<div style="color:green;"></div>'
);
});
it('should not allow svg tags', () => {
const svg = '<svg>foo</svg>';
expect(defaultSanitizer.sanitize(svg)).to.equal('foo');
});
it("should strip 'counter-increment' properties from inline CSS", () => {
const div = '<div style="counter-increment: example-counter;"></div>';
expect(defaultSanitizer.sanitize(div)).to.equal('<div></div>');
});
it('should allow the class attribute for code tags', () => {
const code = '<code class="foo">bar</code>';
expect(defaultSanitizer.sanitize(code)).to.equal(code);
});
it('should allow video tags with some attributes', () => {
const video =
'<video muted="" loop="" controls="" autoplay="" width="42" height="42" src="my/video.mp4"></video>';
expect(defaultSanitizer.sanitize(video)).to.equal(video);
});
it('should pass through simple well-formed whitelisted markup', () => {
const div = '<div><p>Hello <b>there</b></p></div>';
expect(defaultSanitizer.sanitize(div)).to.equal(div);
});