mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-03-24 15:15:14 +08: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.
|
||||
*
|
||||
* @return array{extension: array, data: string}
|
||||
*/
|
||||
protected function parseBase64ImageUri(string $uri): array
|
||||
{
|
||||
[$dataDefinition, $base64ImageData] = explode(',', $uri, 2);
|
||||
$extension = strtolower(preg_split('/[\/;]/', $dataDefinition)[1] ?? '');
|
||||
|
||||
return [
|
||||
'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.
|
||||
*
|
||||
* @throws NotFoundException
|
||||
*/
|
||||
public function listForPage(int $pageId)
|
||||
|
@ -6,7 +6,6 @@ use BookStack\Facades\Activity;
|
||||
use BookStack\Interfaces\Loggable;
|
||||
use BookStack\Model;
|
||||
use BookStack\Util\WebSafeMimeSniffer;
|
||||
use finfo;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Http\Exceptions\HttpResponseException;
|
||||
@ -130,8 +129,7 @@ abstract class Controller extends BaseController
|
||||
*/
|
||||
protected function inlineDownloadResponse(string $content, string $fileName): Response
|
||||
{
|
||||
|
||||
$mime = (new WebSafeMimeSniffer)->sniff($content);
|
||||
$mime = (new WebSafeMimeSniffer())->sniff($content);
|
||||
|
||||
return response()->make($content, 200, [
|
||||
'Content-Type' => $mime,
|
||||
|
@ -15,6 +15,7 @@ class CustomValidationServiceProvider extends ServiceProvider
|
||||
{
|
||||
Validator::extend('image_extension', function ($attribute, $value, $parameters, $validator) {
|
||||
$extension = strtolower($value->getClientOriginalExtension());
|
||||
|
||||
return ImageService::isExtensionSupported($extension);
|
||||
});
|
||||
|
||||
|
@ -17,7 +17,8 @@ class ImageRepo
|
||||
/**
|
||||
* ImageRepo constructor.
|
||||
*/
|
||||
public function __construct(ImageService $imageService, PermissionService $permissionService) {
|
||||
public function __construct(ImageService $imageService, PermissionService $permissionService)
|
||||
{
|
||||
$this->imageService = $imageService;
|
||||
$this->restrictionService = $permissionService;
|
||||
}
|
||||
|
@ -232,6 +232,7 @@ class ImageService
|
||||
* Get the thumbnail for an image.
|
||||
* If $keepRatio is true only the width will be used.
|
||||
* Checks the cache then storage to avoid creating / accessing the filesystem on every check.
|
||||
*
|
||||
* @throws Exception
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
@ -271,7 +272,7 @@ class ImageService
|
||||
{
|
||||
try {
|
||||
$thumb = $this->imageTool->make($imageData);
|
||||
} catch (ErrorException | NotSupportedException $e) {
|
||||
} catch (ErrorException|NotSupportedException $e) {
|
||||
throw new ImageUploadException(trans('errors.cannot_create_thumbs'));
|
||||
}
|
||||
|
||||
@ -452,6 +453,7 @@ class ImageService
|
||||
public function streamImageFromStorageResponse(string $imageType, string $path): StreamedResponse
|
||||
{
|
||||
$disk = $this->getStorageDisk($imageType);
|
||||
|
||||
return $disk->response($path);
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,6 @@ use finfo;
|
||||
*/
|
||||
class WebSafeMimeSniffer
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
@ -61,5 +60,4 @@ class WebSafeMimeSniffer
|
||||
|
||||
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
|
||||
{
|
||||
@ -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
|
||||
{
|
||||
|
@ -614,7 +614,6 @@ class PageContentTest extends TestCase
|
||||
$page->refresh();
|
||||
$this->assertStringContainsString('<img src=""', $page->html);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function test_base64_images_get_extracted_from_markdown_page_content()
|
||||
|
@ -9,7 +9,6 @@ use BookStack\Uploads\Attachment;
|
||||
use BookStack\Uploads\AttachmentService;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Tests\TestCase;
|
||||
use Tests\TestResponse;
|
||||
|
||||
class AttachmentTest extends TestCase
|
||||
{
|
||||
@ -56,6 +55,7 @@ class AttachmentTest extends TestCase
|
||||
$upload = new UploadedFile($filePath, $filename, $mimeType, null, true);
|
||||
|
||||
$this->call('POST', '/attachments/upload', ['uploaded_to' => $page->id], [], ['file' => $upload], []);
|
||||
|
||||
return $page->attachments()->latest()->firstOrFail();
|
||||
}
|
||||
|
||||
@ -340,5 +340,4 @@ class AttachmentTest extends TestCase
|
||||
|
||||
$this->deleteUploads();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user