Skip to content

Commit

Permalink
Fixed issues found from tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ssddanbrown committed Feb 6, 2023
1 parent 9ca088a commit 5e8ec56
Show file tree
Hide file tree
Showing 9 changed files with 112 additions and 118 deletions.
Expand Up @@ -2,25 +2,18 @@

namespace BookStack\Exceptions;

use Whoops\Handler\Handler;
use Illuminate\Contracts\Foundation\ExceptionRenderer;

class WhoopsBookStackPrettyHandler extends Handler
class BookStackExceptionHandlerPage implements ExceptionRenderer
{
/**
* @return int|null A handler may return nothing, or a Handler::HANDLE_* constant
*/
public function handle()
public function render($throwable)
{
$exception = $this->getException();

echo view('errors.debug', [
'error' => $exception->getMessage(),
'errorClass' => get_class($exception),
'trace' => $exception->getTraceAsString(),
return view('errors.debug', [
'error' => $throwable->getMessage(),
'errorClass' => get_class($throwable),
'trace' => $throwable->getTraceAsString(),
'environment' => $this->getEnvironment(),
])->render();

return Handler::QUIT;
}

protected function safeReturn(callable $callback, $default = null)
Expand Down
1 change: 1 addition & 0 deletions app/Exceptions/Handler.php
Expand Up @@ -98,6 +98,7 @@ protected function renderApiException(Throwable $e): JsonResponse
];

if ($e instanceof ValidationException) {
$responseData['error']['message'] = 'The given data was invalid.';
$responseData['error']['validation'] = $e->errors();
$code = $e->status;
}
Expand Down
6 changes: 3 additions & 3 deletions app/Providers/AppServiceProvider.php
Expand Up @@ -8,16 +8,16 @@
use BookStack\Entities\Models\Bookshelf;
use BookStack\Entities\Models\Chapter;
use BookStack\Entities\Models\Page;
use BookStack\Exceptions\WhoopsBookStackPrettyHandler;
use BookStack\Exceptions\BookStackExceptionHandlerPage;
use BookStack\Settings\SettingService;
use BookStack\Util\CspService;
use GuzzleHttp\Client;
use Illuminate\Contracts\Foundation\ExceptionRenderer;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\ServiceProvider;
use Psr\Http\Client\ClientInterface as HttpClientInterface;
use Whoops\Handler\HandlerInterface;

class AppServiceProvider extends ServiceProvider
{
Expand All @@ -26,7 +26,7 @@ class AppServiceProvider extends ServiceProvider
* @var string[]
*/
public $bindings = [
HandlerInterface::class => WhoopsBookStackPrettyHandler::class,
ExceptionRenderer::class => BookStackExceptionHandlerPage::class,
];

/**
Expand Down
2 changes: 1 addition & 1 deletion app/Uploads/ImageService.php
Expand Up @@ -547,7 +547,7 @@ public function pathAccessibleInLocalSecure(string $imagePath): bool
// Check the image file exists
&& $disk->exists($imagePath)
// Check the file is likely an image file
&& strpos($disk->getMimetype($imagePath), 'image/') === 0;
&& strpos($disk->mimeType($imagePath), 'image/') === 0;
}

/**
Expand Down
1 change: 0 additions & 1 deletion composer.json
Expand Up @@ -20,7 +20,6 @@
"barryvdh/laravel-dompdf": "^2.0",
"barryvdh/laravel-snappy": "^1.0",
"doctrine/dbal": "^3.5",
"filp/whoops": "^2.14",
"guzzlehttp/guzzle": "^7.4",
"intervention/image": "^2.7",
"laravel/framework": "^9.0",
Expand Down
190 changes: 95 additions & 95 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5e8ec56

Please sign in to comment.