From 484a892836c3905bd3d9cfd51c4b57f911f06281 Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Mon, 29 May 2017 12:15:23 +0000 Subject: [PATCH] route: catch the regex syntax error correctely git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@3731 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- route.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/route.php b/route.php index 937e519..e52835b 100644 --- a/route.php +++ b/route.php @@ -488,7 +488,13 @@ class route else $regex = str_replace ("}", ">[^/]+)", $regex); unset ($matches); - $rcRegex = preg_match ($regex, $url, $matches); + $rcRegex = @preg_match ($regex, $url, $matches); + if ($rcRegex === false) + { + if (count (error_get_last())) + throw new \Exception ("Invalid regex provided: $regex : ". + error_get_last()["message"], 500); + } if ($rcRegex !== FALSE && $rcRegex !== 0) { if ($this->debug)