From c7a143db0425b9b6a89e39f95a87ebfeff0f7e31 Mon Sep 17 00:00:00 2001 From: Austin Collier Date: Thu, 11 Jan 2024 15:55:30 -0700 Subject: [PATCH] fixed issue with multiline possibilities in url query --- flight/net/Route.php | 2 +- tests/RouterTest.php | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/flight/net/Route.php b/flight/net/Route.php index 2d14bd2..63b1bf0 100644 --- a/flight/net/Route.php +++ b/flight/net/Route.php @@ -135,7 +135,7 @@ final class Route } // Attempt to match route and named parameters - if (preg_match('#^' . $regex . '(?:\?.*)?$#' . (($case_sensitive) ? '' : 'i'), $url, $matches)) { + if (preg_match('#^' . $regex . '(?:\?[\s\S]*)?$#' . (($case_sensitive) ? '' : 'i'), $url, $matches)) { foreach ($ids as $k => $v) { $this->params[$k] = (\array_key_exists($k, $matches)) ? urldecode($matches[$k]) : null; } diff --git a/tests/RouterTest.php b/tests/RouterTest.php index 42e3781..6125f53 100644 --- a/tests/RouterTest.php +++ b/tests/RouterTest.php @@ -255,6 +255,13 @@ class RouterTest extends PHPUnit\Framework\TestCase $this->check('OK'); } + public function testRouteWithLongQueryParamWithMultilineEncoded() + { + $this->router->map('GET /api/intune/hey', [$this, 'ok']); + $this->request->url = '/api/intune/hey?error=access_denied&error_description=AADSTS65004%3a+User+declined+to+consent+to+access+the+app.%0d%0aTrace+ID%3a+747c0cc1-ccbd-4e53-8e2f-48812eb24100%0d%0aCorrelation+ID%3a+362e3cb3-20ef-400b-904e-9983bd989184%0d%0aTimestamp%3a+2022-09-08+09%3a58%3a12Z&error_uri=https%3a%2f%2flogin.microsoftonline.com%2ferror%3fcode%3d65004&admin_consent=True&state=x2EUE0fcSj#'; + $this->check('OK'); + } + // Check if route object was passed public function testRouteObjectPassing() {