mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
Added <a> to comment html sanitizer
refs https://github.com/TryGhost/Team/issues/1664
This commit is contained in:
parent
903b8a1105
commit
9893147d58
1 changed files with 12 additions and 2 deletions
|
@ -51,8 +51,18 @@ const Comment = ghostBookshelf.Model.extend({
|
||||||
const sanitizeHtml = require('sanitize-html');
|
const sanitizeHtml = require('sanitize-html');
|
||||||
|
|
||||||
this.set('html', sanitizeHtml(this.get('html'), {
|
this.set('html', sanitizeHtml(this.get('html'), {
|
||||||
allowedTags: ['p', 'br'],
|
allowedTags: ['p', 'br', 'a'],
|
||||||
selfClosing: ['br']
|
allowedAttributes: {
|
||||||
|
a: ['href', 'target', 'rel']
|
||||||
|
},
|
||||||
|
selfClosing: ['br'],
|
||||||
|
// Enforce _blank and safe URLs
|
||||||
|
transformTags: {
|
||||||
|
a: sanitizeHtml.simpleTransform('a', {
|
||||||
|
target: '_blank',
|
||||||
|
rel: 'ugc noopener noreferrer nofollow'
|
||||||
|
})
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue