mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-28 17:02:04 +03:00
Merge branch 'v23-10' into development
This commit is contained in:
@ -630,6 +630,35 @@ class PageContentTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
@ -663,7 +692,7 @@ class PageContentTest extends TestCase
|
||||
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(), [
|
||||
@ -697,6 +726,34 @@ class PageContentTest extends TestCase
|
||||
$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();
|
||||
|
Reference in New Issue
Block a user