mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Stripped all HTML except <p> and <br> when saving comments
refs https://github.com/TryGhost/Team/issues/1664
This commit is contained in:
parent
38eb755056
commit
379771ccc7
1 changed files with 13 additions and 0 deletions
|
@ -44,6 +44,19 @@ const Comment = ghostBookshelf.Model.extend({
|
|||
ghostBookshelf.Model.prototype.emitChange.bind(this)(this, eventToTrigger, options);
|
||||
},
|
||||
|
||||
onSaving() {
|
||||
ghostBookshelf.Model.prototype.onSaving.apply(this, arguments);
|
||||
|
||||
if (this.hasChanged('html')) {
|
||||
const sanitizeHtml = require('sanitize-html');
|
||||
|
||||
this.set('html', sanitizeHtml(this.get('html'), {
|
||||
allowedTags: ['p', 'br'],
|
||||
selfClosing: ['br']
|
||||
}));
|
||||
}
|
||||
},
|
||||
|
||||
onCreated: function onCreated(model, options) {
|
||||
ghostBookshelf.Model.prototype.onCreated.apply(this, arguments);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue