mirror of
https://github.com/discourse/discourse.git
synced 2025-02-17 16:55:08 +00:00
SECURITY: prevent XSS when showing diffs
This commit is contained in:
parent
001b0710c7
commit
4fb41663b3
@ -3,6 +3,8 @@ import { categoryBadgeHTML } from 'discourse/helpers/category-link';
|
|||||||
import computed from 'ember-addons/ember-computed-decorators';
|
import computed from 'ember-addons/ember-computed-decorators';
|
||||||
import { propertyGreaterThan, propertyLessThan } from 'discourse/lib/computed';
|
import { propertyGreaterThan, propertyLessThan } from 'discourse/lib/computed';
|
||||||
import { on } from 'ember-addons/ember-computed-decorators';
|
import { on } from 'ember-addons/ember-computed-decorators';
|
||||||
|
import { default as WhiteLister } from 'pretty-text/white-lister';
|
||||||
|
import { sanitize } from 'pretty-text/sanitizer';
|
||||||
|
|
||||||
function customTagArray(fieldName) {
|
function customTagArray(fieldName) {
|
||||||
return function() {
|
return function() {
|
||||||
@ -187,7 +189,14 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
|||||||
|
|
||||||
@computed('viewMode', 'model.body_changes')
|
@computed('viewMode', 'model.body_changes')
|
||||||
bodyDiff(viewMode) {
|
bodyDiff(viewMode) {
|
||||||
return this.get("model.body_changes." + viewMode);
|
const html = this.get(`model.body_changes.${viewMode}`);
|
||||||
|
if (viewMode === "side_by_side_markdown") {
|
||||||
|
return html;
|
||||||
|
} else {
|
||||||
|
const whiteLister = new WhiteLister({ features: { editHistory: true }});
|
||||||
|
whiteLister.whiteListFeature("editHistory", { custom: () => true });
|
||||||
|
return sanitize(html, whiteLister);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user