mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-28 17:02:04 +03:00
Fixed content parsing break with line html comment
Fixes issues thrown in custom HMTL head & page content filtering when the content is comprised of only a single HTML comment. Adds tests to cover. For #2804
This commit is contained in:
@ -12,7 +12,7 @@ class ExportTest extends TestCase
|
||||
|
||||
public function test_page_text_export()
|
||||
{
|
||||
$page = Page::first();
|
||||
$page = Page::query()->first();
|
||||
$this->asEditor();
|
||||
|
||||
$resp = $this->get($page->getUrl('/export/plaintext'));
|
||||
@ -23,7 +23,7 @@ class ExportTest extends TestCase
|
||||
|
||||
public function test_page_pdf_export()
|
||||
{
|
||||
$page = Page::first();
|
||||
$page = Page::query()->first();
|
||||
$this->asEditor();
|
||||
|
||||
$resp = $this->get($page->getUrl('/export/pdf'));
|
||||
@ -33,7 +33,7 @@ class ExportTest extends TestCase
|
||||
|
||||
public function test_page_html_export()
|
||||
{
|
||||
$page = Page::first();
|
||||
$page = Page::query()->first();
|
||||
$this->asEditor();
|
||||
|
||||
$resp = $this->get($page->getUrl('/export/html'));
|
||||
@ -44,7 +44,7 @@ class ExportTest extends TestCase
|
||||
|
||||
public function test_book_text_export()
|
||||
{
|
||||
$page = Page::first();
|
||||
$page = Page::query()->first();
|
||||
$book = $page->book;
|
||||
$this->asEditor();
|
||||
|
||||
@ -57,7 +57,7 @@ class ExportTest extends TestCase
|
||||
|
||||
public function test_book_pdf_export()
|
||||
{
|
||||
$page = Page::first();
|
||||
$page = Page::query()->first();
|
||||
$book = $page->book;
|
||||
$this->asEditor();
|
||||
|
||||
@ -68,7 +68,7 @@ class ExportTest extends TestCase
|
||||
|
||||
public function test_book_html_export()
|
||||
{
|
||||
$page = Page::first();
|
||||
$page = Page::query()->first();
|
||||
$book = $page->book;
|
||||
$this->asEditor();
|
||||
|
||||
@ -95,7 +95,7 @@ class ExportTest extends TestCase
|
||||
|
||||
public function test_chapter_text_export()
|
||||
{
|
||||
$chapter = Chapter::first();
|
||||
$chapter = Chapter::query()->first();
|
||||
$page = $chapter->pages[0];
|
||||
$this->asEditor();
|
||||
|
||||
@ -108,7 +108,7 @@ class ExportTest extends TestCase
|
||||
|
||||
public function test_chapter_pdf_export()
|
||||
{
|
||||
$chapter = Chapter::first();
|
||||
$chapter = Chapter::query()->first();
|
||||
$this->asEditor();
|
||||
|
||||
$resp = $this->get($chapter->getUrl('/export/pdf'));
|
||||
@ -118,7 +118,7 @@ class ExportTest extends TestCase
|
||||
|
||||
public function test_chapter_html_export()
|
||||
{
|
||||
$chapter = Chapter::first();
|
||||
$chapter = Chapter::query()->first();
|
||||
$page = $chapter->pages[0];
|
||||
$this->asEditor();
|
||||
|
||||
@ -131,7 +131,7 @@ class ExportTest extends TestCase
|
||||
|
||||
public function test_page_html_export_contains_custom_head_if_set()
|
||||
{
|
||||
$page = Page::first();
|
||||
$page = Page::query()->first();
|
||||
|
||||
$customHeadContent = "<style>p{color: red;}</style>";
|
||||
$this->setSettings(['app-custom-head' => $customHeadContent]);
|
||||
@ -140,9 +140,21 @@ class ExportTest extends TestCase
|
||||
$resp->assertSee($customHeadContent);
|
||||
}
|
||||
|
||||
public function test_page_html_export_does_not_break_with_only_comments_in_custom_head()
|
||||
{
|
||||
$page = Page::query()->first();
|
||||
|
||||
$customHeadContent = "<!-- A comment -->";
|
||||
$this->setSettings(['app-custom-head' => $customHeadContent]);
|
||||
|
||||
$resp = $this->asEditor()->get($page->getUrl('/export/html'));
|
||||
$resp->assertStatus(200);
|
||||
$resp->assertSee($customHeadContent);
|
||||
}
|
||||
|
||||
public function test_page_html_export_use_absolute_dates()
|
||||
{
|
||||
$page = Page::first();
|
||||
$page = Page::query()->first();
|
||||
|
||||
$resp = $this->asEditor()->get($page->getUrl('/export/html'));
|
||||
$resp->assertSee($page->created_at->formatLocalized('%e %B %Y %H:%M:%S'));
|
||||
@ -153,7 +165,7 @@ class ExportTest extends TestCase
|
||||
|
||||
public function test_page_export_does_not_include_user_or_revision_links()
|
||||
{
|
||||
$page = Page::first();
|
||||
$page = Page::query()->first();
|
||||
|
||||
$resp = $this->asEditor()->get($page->getUrl('/export/html'));
|
||||
$resp->assertDontSee($page->getUrl('/revisions'));
|
||||
@ -163,7 +175,7 @@ class ExportTest extends TestCase
|
||||
|
||||
public function test_page_export_sets_right_data_type_for_svg_embeds()
|
||||
{
|
||||
$page = Page::first();
|
||||
$page = Page::query()->first();
|
||||
Storage::disk('local')->makeDirectory('uploads/images/gallery');
|
||||
Storage::disk('local')->put('uploads/images/gallery/svg_test.svg', '<svg></svg>');
|
||||
$page->html = '<img src="http://localhost/uploads/images/gallery/svg_test.svg">';
|
||||
@ -179,7 +191,7 @@ class ExportTest extends TestCase
|
||||
|
||||
public function test_page_image_containment_works_on_multiple_images_within_a_single_line()
|
||||
{
|
||||
$page = Page::first();
|
||||
$page = Page::query()->first();
|
||||
Storage::disk('local')->makeDirectory('uploads/images/gallery');
|
||||
Storage::disk('local')->put('uploads/images/gallery/svg_test.svg', '<svg></svg>');
|
||||
Storage::disk('local')->put('uploads/images/gallery/svg_test2.svg', '<svg></svg>');
|
||||
@ -195,7 +207,7 @@ class ExportTest extends TestCase
|
||||
|
||||
public function test_page_export_contained_html_image_fetches_only_run_when_url_points_to_image_upload_folder()
|
||||
{
|
||||
$page = Page::first();
|
||||
$page = Page::query()->first();
|
||||
$page->html = '<img src="http://localhost/uploads/images/gallery/svg_test.svg"/>'
|
||||
.'<img src="http://localhost/uploads/svg_test.svg"/>'
|
||||
.'<img src="/uploads/svg_test.svg"/>';
|
||||
@ -233,7 +245,7 @@ class ExportTest extends TestCase
|
||||
public function test_page_export_with_deleted_creator_and_updater()
|
||||
{
|
||||
$user = $this->getViewer(['name' => 'ExportWizardTheFifth']);
|
||||
$page = Page::first();
|
||||
$page = Page::query()->first();
|
||||
$page->created_by = $user->id;
|
||||
$page->updated_by = $user->id;
|
||||
$page->save();
|
||||
|
Reference in New Issue
Block a user