From 6d2691c3e259d9eb9a700cc6ee9bd54081d44799 Mon Sep 17 00:00:00 2001 From: jb-oclock Date: Wed, 5 Jul 2023 13:43:47 +0200 Subject: [PATCH] add check for bad basePath --- AltoRouter.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/AltoRouter.php b/AltoRouter.php index 31aa338..d41e54c 100644 --- a/AltoRouter.php +++ b/AltoRouter.php @@ -196,6 +196,14 @@ public function match($requestUrl = null, $requestMethod = null) $requestUrl = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '/'; } + // check if basePath is in requestUrl + // exemple of problem : space in basePath will be replace be %20 in requestUrl + // so next check substr() will not work + if (strpos($requestUrl, $this->basePath) !== 0 ){ + throw new Exception("Error Processing Request : requestUrl is not starting with basePath. Do you forget to use setBasePath() OR basePath contains illegal characters", 1); + } + + // strip base path from request url $requestUrl = substr($requestUrl, strlen($this->basePath));