mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-07-07 20:02:40 +00:00
Applied latest styleci changes
This commit is contained in:
parent
ce3f489188
commit
a17be959d8
|
@ -149,15 +149,17 @@ class PageContent
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse a base64 image URI into the data and extension.
|
* Parse a base64 image URI into the data and extension.
|
||||||
|
*
|
||||||
* @return array{extension: array, data: string}
|
* @return array{extension: array, data: string}
|
||||||
*/
|
*/
|
||||||
protected function parseBase64ImageUri(string $uri): array
|
protected function parseBase64ImageUri(string $uri): array
|
||||||
{
|
{
|
||||||
[$dataDefinition, $base64ImageData] = explode(',', $uri, 2);
|
[$dataDefinition, $base64ImageData] = explode(',', $uri, 2);
|
||||||
$extension = strtolower(preg_split('/[\/;]/', $dataDefinition)[1] ?? '');
|
$extension = strtolower(preg_split('/[\/;]/', $dataDefinition)[1] ?? '');
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'extension' => $extension,
|
'extension' => $extension,
|
||||||
'data' => base64_decode($base64ImageData) ?: '',
|
'data' => base64_decode($base64ImageData) ?: '',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -173,6 +173,7 @@ class AttachmentController extends Controller
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the attachments for a specific page.
|
* Get the attachments for a specific page.
|
||||||
|
*
|
||||||
* @throws NotFoundException
|
* @throws NotFoundException
|
||||||
*/
|
*/
|
||||||
public function listForPage(int $pageId)
|
public function listForPage(int $pageId)
|
||||||
|
|
|
@ -6,7 +6,6 @@ use BookStack\Facades\Activity;
|
||||||
use BookStack\Interfaces\Loggable;
|
use BookStack\Interfaces\Loggable;
|
||||||
use BookStack\Model;
|
use BookStack\Model;
|
||||||
use BookStack\Util\WebSafeMimeSniffer;
|
use BookStack\Util\WebSafeMimeSniffer;
|
||||||
use finfo;
|
|
||||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||||
use Illuminate\Http\Exceptions\HttpResponseException;
|
use Illuminate\Http\Exceptions\HttpResponseException;
|
||||||
|
@ -130,8 +129,7 @@ abstract class Controller extends BaseController
|
||||||
*/
|
*/
|
||||||
protected function inlineDownloadResponse(string $content, string $fileName): Response
|
protected function inlineDownloadResponse(string $content, string $fileName): Response
|
||||||
{
|
{
|
||||||
|
$mime = (new WebSafeMimeSniffer())->sniff($content);
|
||||||
$mime = (new WebSafeMimeSniffer)->sniff($content);
|
|
||||||
|
|
||||||
return response()->make($content, 200, [
|
return response()->make($content, 200, [
|
||||||
'Content-Type' => $mime,
|
'Content-Type' => $mime,
|
||||||
|
|
|
@ -15,6 +15,7 @@ class CustomValidationServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
Validator::extend('image_extension', function ($attribute, $value, $parameters, $validator) {
|
Validator::extend('image_extension', function ($attribute, $value, $parameters, $validator) {
|
||||||
$extension = strtolower($value->getClientOriginalExtension());
|
$extension = strtolower($value->getClientOriginalExtension());
|
||||||
|
|
||||||
return ImageService::isExtensionSupported($extension);
|
return ImageService::isExtensionSupported($extension);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,8 @@ class ImageRepo
|
||||||
/**
|
/**
|
||||||
* ImageRepo constructor.
|
* ImageRepo constructor.
|
||||||
*/
|
*/
|
||||||
public function __construct(ImageService $imageService, PermissionService $permissionService) {
|
public function __construct(ImageService $imageService, PermissionService $permissionService)
|
||||||
|
{
|
||||||
$this->imageService = $imageService;
|
$this->imageService = $imageService;
|
||||||
$this->restrictionService = $permissionService;
|
$this->restrictionService = $permissionService;
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,6 +232,7 @@ class ImageService
|
||||||
* Get the thumbnail for an image.
|
* Get the thumbnail for an image.
|
||||||
* If $keepRatio is true only the width will be used.
|
* If $keepRatio is true only the width will be used.
|
||||||
* Checks the cache then storage to avoid creating / accessing the filesystem on every check.
|
* Checks the cache then storage to avoid creating / accessing the filesystem on every check.
|
||||||
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
* @throws InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
|
@ -271,7 +272,7 @@ class ImageService
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$thumb = $this->imageTool->make($imageData);
|
$thumb = $this->imageTool->make($imageData);
|
||||||
} catch (ErrorException | NotSupportedException $e) {
|
} catch (ErrorException|NotSupportedException $e) {
|
||||||
throw new ImageUploadException(trans('errors.cannot_create_thumbs'));
|
throw new ImageUploadException(trans('errors.cannot_create_thumbs'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -452,6 +453,7 @@ class ImageService
|
||||||
public function streamImageFromStorageResponse(string $imageType, string $path): StreamedResponse
|
public function streamImageFromStorageResponse(string $imageType, string $path): StreamedResponse
|
||||||
{
|
{
|
||||||
$disk = $this->getStorageDisk($imageType);
|
$disk = $this->getStorageDisk($imageType);
|
||||||
|
|
||||||
return $disk->response($path);
|
return $disk->response($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@ use finfo;
|
||||||
*/
|
*/
|
||||||
class WebSafeMimeSniffer
|
class WebSafeMimeSniffer
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string[]
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
|
@ -61,5 +60,4 @@ class WebSafeMimeSniffer
|
||||||
|
|
||||||
return 'application/octet-stream';
|
return 'application/octet-stream';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -242,7 +242,7 @@ class MfaVerificationTest extends TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Array<User, string, TestResponse>
|
* @return array<User, string, TestResponse>
|
||||||
*/
|
*/
|
||||||
protected function startTotpLogin(): array
|
protected function startTotpLogin(): array
|
||||||
{
|
{
|
||||||
|
@ -260,7 +260,7 @@ class MfaVerificationTest extends TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Array<User, string, TestResponse>
|
* @return array<User, string, TestResponse>
|
||||||
*/
|
*/
|
||||||
protected function startBackupCodeLogin($codes = ['kzzu6-1pgll', 'bzxnf-plygd', 'bwdsp-ysl51', '1vo93-ioy7n', 'lf7nw-wdyka', 'xmtrd-oplac']): array
|
protected function startBackupCodeLogin($codes = ['kzzu6-1pgll', 'bzxnf-plygd', 'bwdsp-ysl51', '1vo93-ioy7n', 'lf7nw-wdyka', 'xmtrd-oplac']): array
|
||||||
{
|
{
|
||||||
|
|
|
@ -614,7 +614,6 @@ class PageContentTest extends TestCase
|
||||||
$page->refresh();
|
$page->refresh();
|
||||||
$this->assertStringContainsString('<img src=""', $page->html);
|
$this->assertStringContainsString('<img src=""', $page->html);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_base64_images_get_extracted_from_markdown_page_content()
|
public function test_base64_images_get_extracted_from_markdown_page_content()
|
||||||
|
|
|
@ -9,7 +9,6 @@ use BookStack\Uploads\Attachment;
|
||||||
use BookStack\Uploads\AttachmentService;
|
use BookStack\Uploads\AttachmentService;
|
||||||
use Illuminate\Http\UploadedFile;
|
use Illuminate\Http\UploadedFile;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
use Tests\TestResponse;
|
|
||||||
|
|
||||||
class AttachmentTest extends TestCase
|
class AttachmentTest extends TestCase
|
||||||
{
|
{
|
||||||
|
@ -56,6 +55,7 @@ class AttachmentTest extends TestCase
|
||||||
$upload = new UploadedFile($filePath, $filename, $mimeType, null, true);
|
$upload = new UploadedFile($filePath, $filename, $mimeType, null, true);
|
||||||
|
|
||||||
$this->call('POST', '/attachments/upload', ['uploaded_to' => $page->id], [], ['file' => $upload], []);
|
$this->call('POST', '/attachments/upload', ['uploaded_to' => $page->id], [], ['file' => $upload], []);
|
||||||
|
|
||||||
return $page->attachments()->latest()->firstOrFail();
|
return $page->attachments()->latest()->firstOrFail();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -340,5 +340,4 @@ class AttachmentTest extends TestCase
|
||||||
|
|
||||||
$this->deleteUploads();
|
$this->deleteUploads();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user