Skip to content

Commit

Permalink
Added twitch.tv to allowed sites to be sanitized (#3021)
Browse files Browse the repository at this point in the history
  • Loading branch information
HyperTHD authored Feb 21, 2022
1 parent 1b7ae4c commit 8f04242
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/backend/utils/html/sanitize.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ module.exports = function (dirty) {
},
allowedIframeHostnames: [
'www.youtube.com',
'www.twitch.tv',
'player.vimeo.com',
'giphy.com',
'cdn.embedly.com',
Expand Down
2 changes: 1 addition & 1 deletion src/backend/web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ app.use(
directives: {
defaultSrc: ["'self'"],
fontSrc: ["'self'", 'https:', 'data:'],
frameSrc: ["'self'", '*.youtube.com', '*.vimeo.com'],
frameSrc: ["'self'", '*.youtube.com', '*.vimeo.com', '*.twitch.tv'],
frameAncestors: ["'self'"],
imgSrc: ["'self'", 'data:', 'https:'],
scriptSrc: [
Expand Down
5 changes: 5 additions & 0 deletions test/sanitize-html.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,9 @@ describe('Sanitize HTML', () => {
'<table><tbody><tr><td><a href="www.senecacollege.ca"><img src="https://1.bp.blogspot.com/11.JPG" /></a></td></tr><tr><td>The Final Product</td></tr></tbody></table>'
);
});

test('twitch.tv embedded content should not be removed', () => {
const data = sanitizeHTML('<iframe src="https://www.twitch.tv/0pensrc"></iframe>');
expect(data).toBe('<iframe src="https://www.twitch.tv/0pensrc"></iframe>');
});
});

0 comments on commit 8f04242

Please sign in to comment.