/* eslint no-script-url:0 */ import marked from 'sentry/utils/marked'; function expectMarkdown(test) { expect(marked(test[0])).toEqual('
' + test[1] + '
\n'); } describe('marked', function () { it('normal links get rendered as html', function () { for (const test of [ ['[x](http://example.com)', 'x'], ['[x](https://example.com)', 'x'], ['[x](mailto:foo@example.com)', 'x'], ]) { expectMarkdown(test); } }); it('rejected links should be rendered as plain text', function () { for (const test of [ ['[x](javascript:foo)', 'javascript:foo'], ['[x](java\nscript:foo)', '[x](java\nscript:foo)'], ['[x](data:foo)', 'data:foo'], ['[x](vbscript:foo)', 'vbscript:foo'], ]) { expectMarkdown(test); } }); it('normal images get rendered as html', function () { for (const test of [ ['![](http://example.com)', ''], ['![x](http://example.com)', ''], ['![x](https://example.com)', ''], ]) { expectMarkdown(test); } }); it("rejected images shouldn't be rendered at all", function () { for (const test of [['![x](javascript:foo)', '']]) { expectMarkdown(test); } }); it('escapes XSS and removes invalid attributes on img', function () { [ [ `[test](http://example.com\""#>) ![test](http://example.com"/onerror='alert\(location\)'/)`, `">test `, ], [ '