From 4e08872f683ee0e9e25db7c0b47c7c5d590450bf Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Tue, 24 Jun 2025 12:40:44 +0300 Subject: [PATCH] ref --- application/Espo/Core/Api/Starter.php | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/application/Espo/Core/Api/Starter.php b/application/Espo/Core/Api/Starter.php index 563538c259..892a006012 100644 --- a/application/Espo/Core/Api/Starter.php +++ b/application/Espo/Core/Api/Starter.php @@ -67,17 +67,7 @@ class Starter $slim = SlimAppFactory::create(); if (RouteUtil::isBadUri()) { - $slim->add(function (Psr7Request $request): Psr7Response { - throw new HttpBadRequestException($request, 'Malformed request path: starts with `//`.'); - }); - - $slim->addErrorMiddleware( - displayErrorDetails: false, - logErrors: false, - logErrorDetails: false, - ); - - $slim->run(); + $this->processError($slim); return; } @@ -144,4 +134,19 @@ class Starter $slimRoute->addMiddleware($middleware); } } + + private function processError(SlimApp $slim): void + { + $slim->add(function (Psr7Request $request): Psr7Response { + throw new HttpBadRequestException($request, 'Malformed request path.'); + }); + + $slim->addErrorMiddleware( + displayErrorDetails: false, + logErrors: false, + logErrorDetails: false, + ); + + $slim->run(); + } }