mirror of
https://github.com/laurent22/joplin.git
synced 2025-03-06 15:36:49 +02:00
21 lines
653 B
TypeScript
21 lines
653 B
TypeScript
|
import { processPastedHtml } from './resourceHandling';
|
||
|
|
||
|
describe('resourceHandling', () => {
|
||
|
it('should sanitize pasted HTML', async () => {
|
||
|
const testCases = [
|
||
|
['Test: <style onload="evil()"></style>', 'Test: <style></style>'],
|
||
|
['<a href="javascript: alert()">test</a>', '<a href="#">test</a>'],
|
||
|
['<script >evil()</script>', ''],
|
||
|
['<script>evil()</script>', ''],
|
||
|
[
|
||
|
'<img onload="document.body.innerHTML = evil;" src="data:image/svg+xml;base64,=="/>',
|
||
|
'<img src="data:image/svg+xml;base64,=="/>',
|
||
|
],
|
||
|
];
|
||
|
|
||
|
for (const [html, expected] of testCases) {
|
||
|
expect(await processPastedHtml(html)).toBe(expected);
|
||
|
}
|
||
|
});
|
||
|
});
|