mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 18:29:27 +02:00
Handle HTML is comments
This commit is contained in:
parent
c3badc81fe
commit
2890b615f3
11 changed files with 100 additions and 114 deletions
|
@ -1,7 +1,6 @@
|
|||
import * as validator from 'validator'
|
||||
import { exists, isDateValid } from '../misc'
|
||||
import { isActivityPubUrlValid, isBaseActivityValid } from './misc'
|
||||
import * as sanitizeHtml from 'sanitize-html'
|
||||
|
||||
function isVideoCommentCreateActivityValid (activity: any) {
|
||||
return isBaseActivityValid(activity, 'Create') &&
|
||||
|
@ -11,7 +10,6 @@ function isVideoCommentCreateActivityValid (activity: any) {
|
|||
function isVideoCommentObjectValid (comment: any) {
|
||||
return comment.type === 'Note' &&
|
||||
isActivityPubUrlValid(comment.id) &&
|
||||
sanitizeCommentHTML(comment) &&
|
||||
isCommentContentValid(comment.content) &&
|
||||
isActivityPubUrlValid(comment.inReplyTo) &&
|
||||
isDateValid(comment.published) &&
|
||||
|
@ -31,15 +29,6 @@ export {
|
|||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function sanitizeCommentHTML (comment: any) {
|
||||
return sanitizeHtml(comment.content, {
|
||||
allowedTags: [ 'b', 'i', 'em', 'span', 'a' ],
|
||||
allowedAttributes: {
|
||||
'a': [ 'href' ]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function isCommentContentValid (content: any) {
|
||||
return exists(content) && validator.isLength('' + content, { min: 1 })
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue