From 9290f1d2a7011a17ea3837a00cebae3b09c9ef07 Mon Sep 17 00:00:00 2001 From: printempw <h@prinzeugen.net> Date: Mon, 29 Aug 2016 15:10:51 +0800 Subject: [PATCH] fix rendering HttpException with whoops --- app/Exceptions/Handler.php | 5 +++++ app/Http/Middleware/CheckPlayerExistMiddleware.php | 10 ++-------- app/Http/routes.php | 2 +- resources/views/errors/404.tpl | 2 +- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 847d3c18..ef8d106a 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -47,6 +47,11 @@ class Handler extends ExceptionHandler } if (config('app.debug')) { + foreach ($this->dontReport as $type) { + if ($e instanceof $type) { + return parent::render($request, $e); + } + } return $this->renderExceptionWithWhoops($e); } diff --git a/app/Http/Middleware/CheckPlayerExistMiddleware.php b/app/Http/Middleware/CheckPlayerExistMiddleware.php index 5dbd3a12..47cfe89e 100644 --- a/app/Http/Middleware/CheckPlayerExistMiddleware.php +++ b/app/Http/Middleware/CheckPlayerExistMiddleware.php @@ -14,15 +14,9 @@ class CheckPlayerExistMiddleware preg_match('/\/([^\/]*)\.png/', $request->getUri(), $matches); } - $player_name = $matches[1]; + $player_name = urldecode($matches[1]); - if (\Option::get('allow_chinese_playername')) { - $player_name = urldecode($player_name); - // quick fix of chinese playername route parameter problem - $GLOBALS['player_name'] = $player_name; - } - - if (!PlayerModel::where('player_name', $player_name)->count()) { + if (PlayerModel::where('player_name', $player_name)->get()->isEmpty()) { \Http::abort(404, '角色不存在'); } diff --git a/app/Http/routes.php b/app/Http/routes.php index 2a4388a0..08d4fec7 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -118,7 +118,7 @@ Route::group(['middleware' => 'App\Http\Middleware\CheckPlayer { // Json profile Route::get('/{player_name}.json', 'TextureController@json'); - Route::get('/{api}/{player_name}.json', 'TextureController@jsonWithApi'); + Route::get('/{api}/{player_name}.json', 'TextureController@jsonWithApi')->where('api', 'usm|csl'); // Legacy links Route::get('/skin/{player_name}.png', 'TextureController@skin'); Route::get('/cape/{player_name}.png', 'TextureController@cape'); diff --git a/resources/views/errors/404.tpl b/resources/views/errors/404.tpl index d0246f10..c2be6bae 100644 --- a/resources/views/errors/404.tpl +++ b/resources/views/errors/404.tpl @@ -5,5 +5,5 @@ @section('content') <h1>404 Not Found</h1> -<p>详细信息:{{ $message or "Nothing lives here.." }}</p> +<p>详细信息:{{ $message or "这里啥都没有哦" }}</p> @endsection