NOW MANAGED ON CODEBERG
Fixed issue where page export contain system would miss images
Dan Brown6c09334ba07e
diff --git a/app/Entities/Tools/ExportFormatter.php b/app/Entities/Tools/ExportFormatter.phpindex 92469a9b0..9cf8b56af 100644--- a/app/Entities/Tools/ExportFormatter.php+++ b/app/Entities/Tools/ExportFormatter.php@@ -143,7 +143,7 @@ class ExportFormatterprotected function containHtml(string $htmlContent): string{$imageTagsOutput = [];- preg_match_all("/\<img.*src\=(\'|\")(.*?)(\'|\").*?\>/i", $htmlContent, $imageTagsOutput);+ preg_match_all("/\<img.*?src\=(\'|\")(.*?)(\'|\").*?\>/i", $htmlContent, $imageTagsOutput);// Replace image src with base64 encoded image stringsif (isset($imageTagsOutput[0]) && count($imageTagsOutput[0]) > 0) {diff --git a/tests/Entity/ExportTest.php b/tests/Entity/ExportTest.phpindex 7c56a7268..1e44f015a 100644--- a/tests/Entity/ExportTest.php+++ b/tests/Entity/ExportTest.php@@ -167,12 +167,28 @@ class ExportTest extends TestCase$resp->assertSee('<img src="data:image/svg+xml;base64');}+ public function test_page_image_containment_works_on_multiple_images_within_a_single_line()+ {+ $page = Page::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>');+ $page->html = '<img src="http://localhost/uploads/images/gallery/svg_test.svg" class="a"><img src="http://localhost/uploads/images/gallery/svg_test2.svg" class="b">';+ $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 = '<img src="http://localhost/uploads/images/gallery/svg_test.svg"/>'- ."\n".'<img src="http://localhost/uploads/svg_test.svg"/>'- ."\n".'<img src="/uploads/svg_test.svg"/>';+ .'<img src="http://localhost/uploads/svg_test.svg"/>'+ .'<img src="/uploads/svg_test.svg"/>';$storageDisk = Storage::disk('local');$storageDisk->makeDirectory('uploads/images/gallery');$storageDisk->put('uploads/images/gallery/svg_test.svg', '<svg>good</svg>');