Skip to content

Commit

Permalink
Fix reply content not syncing or syncing old value
Browse files Browse the repository at this point in the history
  • Loading branch information
clarkwinkelmann committed Jun 27, 2022
1 parent 90ac029 commit fec1f74
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Model/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ public function toSearchableArray(): array

return [
// TODO: convert $this to CommentPost to use as context?
'content' => $formatter->unparse($this->getOriginal('content'), $this),
// We use the rendered version and not unparsed version as the unparsed version might expose original text that's hidden by extensions in the output
// strip_tags is used to strip HTML tags and their properties from the index but not provide any additional security
'content' => strip_tags($formatter->render($this->content ?? '<t></t>', $this)),
];
}

Expand Down
2 changes: 2 additions & 0 deletions src/ScoutServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Flarum\Discussion\Discussion;
use Flarum\Foundation\AbstractServiceProvider;
use Flarum\Post\CommentPost;
use Flarum\Post\Post;
use Flarum\Settings\SettingsRepositoryInterface;
use Flarum\User\User;
Expand Down Expand Up @@ -38,6 +39,7 @@ public function register()

public function boot()
{
CommentPost::observe(new FlarumModelObserver());
Discussion::observe(new FlarumModelObserver());
Post::observe(new FlarumModelObserver());
User::observe(new FlarumModelObserver());
Expand Down

0 comments on commit fec1f74

Please sign in to comment.