|
|
@ -1,6 +1,6 @@ |
|
|
|
import { sanitizeTextPanelContent, sanitizeUrl, sanitize } from './sanitize'; |
|
|
|
import { sanitizeTextPanelContent, sanitizeUrl, sanitize } from './sanitize'; |
|
|
|
|
|
|
|
|
|
|
|
describe('Sanitize wrapper', () => { |
|
|
|
describe('sanitizeTextPanelContent', () => { |
|
|
|
it('should allow whitelisted styles in text panel', () => { |
|
|
|
it('should allow whitelisted styles in text panel', () => { |
|
|
|
const html = |
|
|
|
const html = |
|
|
|
'<div style="display:flex; flex-direction: column; flex-wrap: wrap; justify-content: start; gap: 2px;"><div style="flex-basis: 50%"></div></div>'; |
|
|
|
'<div style="display:flex; flex-direction: column; flex-wrap: wrap; justify-content: start; gap: 2px;"><div style="flex-basis: 50%"></div></div>'; |
|
|
@ -9,6 +9,28 @@ describe('Sanitize wrapper', () => { |
|
|
|
'<div style="display:flex; flex-direction:column; flex-wrap:wrap; justify-content:start; gap:2px;"><div style="flex-basis:50%;"></div></div>' |
|
|
|
'<div style="display:flex; flex-direction:column; flex-wrap:wrap; justify-content:start; gap:2px;"><div style="flex-basis:50%;"></div></div>' |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it('should escape xss payload', () => { |
|
|
|
|
|
|
|
const html = '<script>alert(1)</script>'; |
|
|
|
|
|
|
|
const str = sanitizeTextPanelContent(html); |
|
|
|
|
|
|
|
expect(str).toBe('<script>alert(1)</script>'); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it('should allow markdown generated unstyled disabled checkbox inputs', () => { |
|
|
|
|
|
|
|
const str = sanitizeTextPanelContent(`<input disabled="" type="checkbox">
|
|
|
|
|
|
|
|
<input checked="" disabled="" type="checkbox">`);
|
|
|
|
|
|
|
|
expect(str).toMatch(/<input disabled(="")? type="checkbox">/); |
|
|
|
|
|
|
|
expect(str).toMatch(/<input checked(="")? disabled(="")? type="checkbox">/); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it('should sanitize arbitrary input elements', () => { |
|
|
|
|
|
|
|
const str = sanitizeTextPanelContent(`<input>
|
|
|
|
|
|
|
|
<input type="text"> |
|
|
|
|
|
|
|
<input disabled="" type="radio"> |
|
|
|
|
|
|
|
<input disabled="" type="checkbox" class="some-class"> |
|
|
|
|
|
|
|
<input checked="" disabled="" type="checkbox" class="some-class">`);
|
|
|
|
|
|
|
|
expect(str).not.toMatch(/<input/); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
describe('sanitizeUrl', () => { |
|
|
|
describe('sanitizeUrl', () => { |
|
|
|