From b8fb6bc8151956d714706d7e1b43b5d732ce314c Mon Sep 17 00:00:00 2001 From: Marcos Steverlynck <26821235+massa-man@users.noreply.github.com> Date: Fri, 31 Jan 2025 18:11:27 +0000 Subject: [PATCH 1/2] bugfix(errors): fix url issue were HTTP_HOST server var already includes port --- errors/processor.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/errors/processor.php b/errors/processor.php index 99b117c7e4d..e872d0718ed 100644 --- a/errors/processor.php +++ b/errors/processor.php @@ -185,6 +185,9 @@ public function getHostUrl(): string if (!empty($_SERVER['SERVER_PORT']) && preg_match('/\d+/', $_SERVER['SERVER_PORT']) && !in_array($_SERVER['SERVER_PORT'], [80, 433]) + && (strlen($host) <= strlen(':' . $_SERVER['SERVER_PORT']) + || substr_compare($host, ':' . $_SERVER['SERVER_PORT'], -strlen(':' . $_SERVER['SERVER_PORT'])) !== 0 + ) ) { $url .= ':' . $_SERVER['SERVER_PORT']; } From 3366216bf78bb2dfcc214e28c7e0f3c1d08337c4 Mon Sep 17 00:00:00 2001 From: Marcos Steverlynck <26821235+massa-man@users.noreply.github.com> Date: Sat, 1 Feb 2025 14:46:36 +0000 Subject: [PATCH 2/2] bugfix(errors): use str_ends_with instead of substr_compare and run cs fixer --- errors/processor.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/errors/processor.php b/errors/processor.php index e872d0718ed..1bace5205c0 100644 --- a/errors/processor.php +++ b/errors/processor.php @@ -185,12 +185,11 @@ public function getHostUrl(): string if (!empty($_SERVER['SERVER_PORT']) && preg_match('/\d+/', $_SERVER['SERVER_PORT']) && !in_array($_SERVER['SERVER_PORT'], [80, 433]) - && (strlen($host) <= strlen(':' . $_SERVER['SERVER_PORT']) - || substr_compare($host, ':' . $_SERVER['SERVER_PORT'], -strlen(':' . $_SERVER['SERVER_PORT'])) !== 0 - ) + && !str_ends_with($host, ':' . $_SERVER['SERVER_PORT']) ) { $url .= ':' . $_SERVER['SERVER_PORT']; } + return $url; }