From e8cc10ec2db9673c04b825c5e186358d1e100e94 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Thu, 20 Feb 2020 22:42:54 +0200 Subject: [PATCH] Added proper error handling --- app/app.php | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/app/app.php b/app/app.php index 089598edcf..1cba331488 100644 --- a/app/app.php +++ b/app/app.php @@ -369,27 +369,19 @@ $utopia->get('/.well-known/acme-challenge') $absolute = realpath($base.'/'.$path); if(!$absolute) { - //throw new Exception('Unknown Path', 404); - $response->json([ - 'error' => 'unknown path', - 'base' => scandir($base), - 'base/well' => scandir($base . '/.well-known/'), - 'base/well/acme' => scandir($base . '/.well-known/acme-challenge/'), - 'base/well/acme/query' => ($absolute) ? scandir($absolute) : ['not-a-dir'], - ]); - return; + throw new Exception('Unknown Path', 404); + // $response->json([ + // 'error' => 'unknown path', + // 'base' => scandir($base), + // 'base/well' => scandir($base . '/.well-known/'), + // 'base/well/acme' => scandir($base . '/.well-known/acme-challenge/'), + // 'base/well/acme/query' => ($absolute) ? scandir($absolute) : ['not-a-dir'], + // ]); + // return; } if(!substr($absolute, 0, strlen($base)) === $base) { - //throw new Exception('Invalid Path', 401); - $response->json([ - 'error' => 'invalid path', - 'base' => scandir($base), - 'base/well' => scandir($base . '/.well-known/'), - 'base/well/acme' => scandir($base . '/.well-known/acme-challenge/'), - 'base/well/acme/query' => ($absolute) ? scandir($absolute) : ['not-a-dir'], - ]); - return; + throw new Exception('Invalid Path', 401); } $response->text(file_get_contents($absolute));