1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-30 04:23:11 +03:00

Added drawing endpoint tests

Also refactored ImageTests away from BrowserKit
Also added image upload type validation.
This commit is contained in:
Dan Brown
2018-01-28 13:18:28 +00:00
parent 9bbef3a3dd
commit 88d09a2a3b
7 changed files with 119 additions and 28 deletions

View File

@ -120,7 +120,10 @@ class ImageController extends Controller
$this->validate($request, [
'file' => 'is_image'
]);
// TODO - Restrict & validate types
if (!$this->imageRepo->isValidType($type)) {
return $this->jsonError(trans('errors.image_upload_type_error'));
}
$imageUpload = $request->file('file');

View File

@ -1,12 +1,9 @@
<?php namespace BookStack\Repos;
use BookStack\Image;
use BookStack\Page;
use BookStack\Services\ImageService;
use BookStack\Services\PermissionService;
use Illuminate\Contracts\Filesystem\FileNotFoundException;
use Setting;
use Symfony\Component\HttpFoundation\File\UploadedFile;
class ImageRepo
@ -247,5 +244,15 @@ class ImageRepo
}
}
/**
* Check if the provided image type is valid.
* @param $type
* @return bool
*/
public function isValidType($type)
{
$validTypes = ['drawing', 'gallery', 'cover', 'system', 'user'];
return in_array($type, $validTypes);
}
}