Skip to content

Commit

Permalink
xss injection security
Browse files Browse the repository at this point in the history
  • Loading branch information
justoverclockl committed May 8, 2022
1 parent 56a95de commit 86c5fc4
Show file tree
Hide file tree
Showing 6 changed files with 1,565 additions and 1,541 deletions.
3 changes: 2 additions & 1 deletion js/dist/forum.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions js/dist/forum.js.LICENSE.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion js/dist/forum.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
},
"prettier": "@flarum/prettier-config",
"dependencies": {
"dompurify": "^2.3.6",
"flarum": "^0.1.0-beta.16"
}
}
18 changes: 17 additions & 1 deletion js/src/forum/components/FirstVisitPopup.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Modal from 'flarum/common/components/Modal';
import app from 'flarum/forum/app';
import DOMPurify from 'dompurify';

export default class CustomModal extends Modal {
static isDismissible = true;
Expand All @@ -8,7 +9,22 @@ export default class CustomModal extends Modal {
super.oncreate(vnode);
const modalContent = app.forum.attribute('justoverclock-first-visit-popup.modalContent');
const modal = document.getElementById('fvp-modal');
modal.innerHTML = modalContent;
modal.innerHTML = DOMPurify.sanitize(modalContent, {
USE_PROFILES: { html: true },
FORCE_BODY: true,
ALLOWED_ATTR: ['style', 'class', 'type', 'href', 'rel'],
ALLOWED_TAGS: [
'link',
'figure',
'table',
'caption',
'thead',
'tr',
'th',
'tbody',
'td',
],
});
}

className() {
Expand Down
Loading

0 comments on commit 86c5fc4

Please sign in to comment.