Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions packages/decap-cms-widget-markdown/src/__tests__/renderer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,17 @@ I get 10 times more traffic from [Google] than from [Yahoo] or [MSN].
expect(img).not.toHaveAttribute('onerror');
});

it('should sanitize HTML by default when sanitize_preview is unset', async () => {
const value = `<img src="foobar.png" onerror="alert('hello')">`;

const { container } = render(
<MarkdownPreview value={value} getAsset={jest.fn()} resolveWidget={jest.fn()} />,
);
const img = container.querySelector('img');
expect(img).toHaveAttribute('src', 'foobar.png');
expect(img).not.toHaveAttribute('onerror');
});

it('should sanitize dangerous link protocols', () => {
const value = '<a href="javascript:alert(1)">click</a>';

Expand Down