From: Dan Brown Date: Sun, 6 Dec 2020 22:23:21 +0000 (+0000) Subject: Fixed issue where page export contain system would miss images X-Git-Tag: v0.31.0~3^2~24 X-Git-Url: http://source.bookstackapp.com/bookstack/commitdiff_plain/6c09334ba07e6ca76405311aea816991081fb4c2 Fixed issue where page export contain system would miss images --- diff --git a/app/Entities/Tools/ExportFormatter.php b/app/Entities/Tools/ExportFormatter.php index 92469a9b0..9cf8b56af 100644 --- a/app/Entities/Tools/ExportFormatter.php +++ b/app/Entities/Tools/ExportFormatter.php @@ -143,7 +143,7 @@ class ExportFormatter protected function containHtml(string $htmlContent): string { $imageTagsOutput = []; - preg_match_all("/\/i", $htmlContent, $imageTagsOutput); + preg_match_all("/\/i", $htmlContent, $imageTagsOutput); // Replace image src with base64 encoded image strings if (isset($imageTagsOutput[0]) && count($imageTagsOutput[0]) > 0) { diff --git a/tests/Entity/ExportTest.php b/tests/Entity/ExportTest.php index 7c56a7268..1e44f015a 100644 --- a/tests/Entity/ExportTest.php +++ b/tests/Entity/ExportTest.php @@ -167,12 +167,28 @@ class ExportTest extends TestCase $resp->assertSee(''; + $page->save(); + + $resp = $this->asEditor()->get($page->getUrl('/export/html')); + Storage::disk('local')->delete('uploads/images/gallery/svg_test.svg'); + Storage::disk('local')->delete('uploads/images/gallery/svg_test2.svg'); + + $resp->assertDontSee('http://localhost/uploads/images/gallery/svg_test'); + } + public function test_page_export_contained_html_image_fetches_only_run_when_url_points_to_image_upload_folder() { $page = Page::first(); $page->html = '' - ."\n".'' - ."\n".''; + .'' + .''; $storageDisk = Storage::disk('local'); $storageDisk->makeDirectory('uploads/images/gallery'); $storageDisk->put('uploads/images/gallery/svg_test.svg', 'good');