X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/421dd93ffd59bbe881df1f7fa86066f7f353b596..refs/pull/2393/head:/tests/Entity/PageContentTest.php diff --git a/tests/Entity/PageContentTest.php b/tests/Entity/PageContentTest.php index b447a7c5d..51a8568bf 100644 --- a/tests/Entity/PageContentTest.php +++ b/tests/Entity/PageContentTest.php @@ -1,8 +1,8 @@ -assertStatus(302); $page = Page::find($page->id); - $this->assertContains($includeTag, $page->html); + $this->assertStringContainsString($includeTag, $page->html); $this->assertEquals('', $page->text); } @@ -71,6 +71,25 @@ class PageContentTest extends TestCase $pageResp->assertSee($content); } + public function test_page_includes_rendered_on_book_export() + { + $page = Page::query()->first(); + $secondPage = Page::query() + ->where('book_id', '!=', $page->book_id) + ->first(); + + $content = '
my cat is awesome and scratchy
'; + $secondPage->html = $content; + $secondPage->save(); + + $page->html = "{{@{$secondPage->id}#bkmrk-meow}}"; + $page->save(); + + $this->asEditor(); + $htmlContent = $this->get($page->book->getUrl('/export/html')); + $htmlContent->assertSee('my cat is awesome and scratchy'); + } + public function test_page_content_scripts_removed_by_default() { $this->asEditor(); @@ -118,7 +137,7 @@ class PageContentTest extends TestCase '', '', '', - + '' ]; $this->asEditor(); @@ -140,6 +159,72 @@ class PageContentTest extends TestCase } + public function test_javascript_uri_links_are_removed() + { + $checks = [ + ''); + $pageView->assertElementNotContains('.page-content', 'href=javascript:'); + } + } + public function test_form_actions_with_javascript_are_removed() + { + $checks = [ + '', + '', + '' + ]; + + $this->asEditor(); + $page = Page::first(); + + foreach ($checks as $check) { + $page->html = $check; + $page->save(); + + $pageView = $this->get($page->getUrl()); + $pageView->assertStatus(200); + $pageView->assertElementNotContains('.page-content', '