mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-05-16 13:31:25 +00:00
Comments: Added HTML filter on load, tinymce elem filtering
- Added filter on load to help prevent potentially dangerous comment HTML in DB at load time (if it gets passed input filtering, or is existing). - Added TinyMCE valid_elements for input wysiwygs, to gracefully degrade content at point of user-view, rather than surprising the user by stripping content, which TinyMCE would show, post-save.
This commit is contained in:
parent
e9a19d5878
commit
06901b878f
4 changed files with 27 additions and 4 deletions
tests/Entity
|
@ -82,11 +82,10 @@ class CommentTest extends TestCase
|
|||
|
||||
public function test_scripts_cannot_be_injected_via_comment_html()
|
||||
{
|
||||
$this->asAdmin();
|
||||
$page = $this->entities->page();
|
||||
|
||||
$script = '<script>const a = "script";</script><p onclick="1">My lovely comment</p>';
|
||||
$this->postJson("/comment/$page->id", [
|
||||
$this->asAdmin()->postJson("/comment/$page->id", [
|
||||
'html' => $script,
|
||||
]);
|
||||
|
||||
|
@ -104,6 +103,20 @@ class CommentTest extends TestCase
|
|||
$pageView->assertSee('<p>My lovely comment</p><p>updated</p>');
|
||||
}
|
||||
|
||||
public function test_scripts_are_removed_even_if_already_in_db()
|
||||
{
|
||||
$page = $this->entities->page();
|
||||
Comment::factory()->create([
|
||||
'html' => '<script>superbadscript</script><p onclick="superbadonclick">scriptincommentest</p>',
|
||||
'entity_type' => 'page', 'entity_id' => $page
|
||||
]);
|
||||
|
||||
$resp = $this->asAdmin()->get($page->getUrl());
|
||||
$resp->assertSee('scriptincommentest', false);
|
||||
$resp->assertDontSee('superbadscript', false);
|
||||
$resp->assertDontSee('superbadonclick', false);
|
||||
}
|
||||
|
||||
public function test_reply_comments_are_nested()
|
||||
{
|
||||
$this->asAdmin();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue