mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-01 01:36:00 -04:00
Replaced embeds with images in exports
This commit is contained in:
parent
05f8034439
commit
bf0ba9f756
@ -215,9 +215,12 @@ class ExportFormatter
|
||||
*/
|
||||
protected function containHtml(string $htmlContent): string
|
||||
{
|
||||
// Replace embed tags with images
|
||||
$htmlContent = preg_replace("/<embed (.*?)>/i", '<img $1>', $htmlContent);
|
||||
|
||||
// Replace image & embed src attributes with base64 encoded data strings
|
||||
$imageTagsOutput = [];
|
||||
preg_match_all("/<(?:img|embed) .*?src=['\"](.*?)['\"].*?>/i", $htmlContent, $imageTagsOutput);
|
||||
preg_match_all("/<img .*?src=['\"](.*?)['\"].*?>/i", $htmlContent, $imageTagsOutput);
|
||||
if (isset($imageTagsOutput[0]) && count($imageTagsOutput[0]) > 0) {
|
||||
foreach ($imageTagsOutput[0] as $index => $imgMatch) {
|
||||
$oldImgTagString = $imgMatch;
|
||||
|
@ -258,7 +258,7 @@ class ExportTest extends TestCase
|
||||
unlink($testFilePath);
|
||||
}
|
||||
|
||||
public function test_page_export_contained_html_embed_element_srcs_are_inlined()
|
||||
public function test_page_export_contained_html_embed_elements_are_converted_to_images_with_srcs_inlined()
|
||||
{
|
||||
$page = Page::query()->first();
|
||||
$page->html = '<embed src="http://localhost/uploads/images/gallery/svg_test.svg"/>';
|
||||
@ -273,7 +273,7 @@ class ExportTest extends TestCase
|
||||
$storageDisk->delete('uploads/images/gallery/svg_test.svg');
|
||||
|
||||
$resp->assertDontSee('http://localhost/uploads/images/gallery/svg_test.svg', false);
|
||||
$resp->assertSee('<embed src="data:image/svg+xml;base64,PHN2Zz5nb29kPC9zdmc+">', false);
|
||||
$resp->assertSee('<img src="data:image/svg+xml;base64,PHN2Zz5nb29kPC9zdmc+">', false);
|
||||
}
|
||||
|
||||
public function test_exports_removes_scripts_from_custom_head()
|
||||
|
Loading…
Reference in New Issue
Block a user