1
0
Fork 0
mirror of synced 2024-07-01 04:30:59 +12:00

Added proper error handling

This commit is contained in:
Eldad Fux 2020-02-20 22:42:54 +02:00
parent fe5d9107c0
commit e8cc10ec2d

View file

@ -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));