}
}
+ public function test_base64_images_within_html_blanked_if_no_image_create_permission()
+ {
+ $editor = $this->users->editor();
+ $page = $this->entities->page();
+ $this->permissions->removeUserRolePermissions($editor, ['image-create-all']);
+
+ $this->actingAs($editor)->put($page->getUrl(), [
+ 'name' => $page->name,
+ 'html' => '<p>test<img src="data:image/jpeg;base64,' . $this->base64Jpeg . '"/></p>',
+ ]);
+
+ $page->refresh();
+ $this->assertStringMatchesFormat('%A<p%A>test<img src="">%A</p>%A', $page->html);
+ }
+
+ public function test_base64_images_within_html_blanked_if_content_does_not_appear_like_an_image()
+ {
+ $page = $this->entities->page();
+
+ $imgContent = base64_encode('file://test/a/b/c');
+ $this->asEditor()->put($page->getUrl(), [
+ 'name' => $page->name,
+ 'html' => '<p>test<img src="data:image/jpeg;base64,' . $imgContent . '"/></p>',
+ ]);
+
+ $page->refresh();
+ $this->assertStringMatchesFormat('%A<p%A>test<img src="">%A</p>%A', $page->html);
+ }
+
public function test_base64_images_get_extracted_from_markdown_page_content()
{
$this->asEditor();
ini_set('pcre.backtrack_limit', '500');
ini_set('pcre.recursion_limit', '500');
- $content = str_repeat('a', 5000);
+ $content = str_repeat(base64_decode($this->base64Jpeg), 50);
$base64Content = base64_encode($content);
$this->put($page->getUrl(), [
$this->assertStringContainsString('<img src=""', $page->refresh()->html);
}
+ public function test_base64_images_within_markdown_blanked_if_no_image_create_permission()
+ {
+ $editor = $this->users->editor();
+ $page = $this->entities->page();
+ $this->permissions->removeUserRolePermissions($editor, ['image-create-all']);
+
+ $this->actingAs($editor)->put($page->getUrl(), [
+ 'name' => $page->name,
+ 'markdown' => 'test ',
+ ]);
+
+ $this->assertStringContainsString('<img src=""', $page->refresh()->html);
+ }
+
+ public function test_base64_images_within_markdown_blanked_if_content_does_not_appear_like_an_image()
+ {
+ $page = $this->entities->page();
+
+ $imgContent = base64_encode('file://test/a/b/c');
+ $this->asEditor()->put($page->getUrl(), [
+ 'name' => $page->name,
+ 'markdown' => 'test ',
+ ]);
+
+ $page->refresh();
+ $this->assertStringContainsString('<img src=""', $page->refresh()->html);
+ }
+
public function test_nested_headers_gets_assigned_an_id()
{
$page = $this->entities->page();