diff --git a/app/Activity/Models/Comment.php b/app/Activity/Models/Comment.php index 6efa3df6f..038788afb 100644 --- a/app/Activity/Models/Comment.php +++ b/app/Activity/Models/Comment.php @@ -4,6 +4,7 @@ namespace BookStack\Activity\Models; use BookStack\App\Model; use BookStack\Users\Models\HasCreatorAndUpdater; +use BookStack\Util\HtmlContentFilter; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\MorphTo; @@ -73,4 +74,9 @@ class Comment extends Model implements Loggable { return "Comment #{$this->local_id} (ID: {$this->id}) for {$this->entity_type} (ID: {$this->entity_id})"; } + + public function safeHtml(): string + { + return HtmlContentFilter::removeScriptsFromHtmlString($this->html ?? ''); + } } diff --git a/resources/js/wysiwyg/config.js b/resources/js/wysiwyg/config.js index 36d78b325..fa2df9c11 100644 --- a/resources/js/wysiwyg/config.js +++ b/resources/js/wysiwyg/config.js @@ -339,6 +339,7 @@ export function buildForInput(options) { toolbar: 'bold italic link bullist numlist', content_style: getContentStyle(options), file_picker_types: 'file', + valid_elements: 'p,a[href|title],ol,ul,li,strong,em,br', file_picker_callback: filePickerCallback, init_instance_callback(editor) { addCustomHeadContent(editor.getDoc()); diff --git a/resources/views/comments/comment.blade.php b/resources/views/comments/comment.blade.php index e00307f0f..b507a810b 100644 --- a/resources/views/comments/comment.blade.php +++ b/resources/views/comments/comment.blade.php @@ -1,3 +1,6 @@ +@php + $commentHtml = $comment->safeHtml(); +@endphp