From c92b9db3745dafae6412879af57bcc3e8cb6b8ab Mon Sep 17 00:00:00 2001 From: Sven Schultschik Date: Fri, 23 Feb 2024 18:10:33 +0100 Subject: [PATCH 1/4] fix cli scheduler:run breaks if --live-site does not end with / Signed-off-by: Sven Schultschik --- src/AbstractWebApplication.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/AbstractWebApplication.php b/src/AbstractWebApplication.php index a7d3522f..bfab4fbc 100644 --- a/src/AbstractWebApplication.php +++ b/src/AbstractWebApplication.php @@ -817,7 +817,11 @@ protected function detectRequestUri() } else { // If not in "Apache Mode" we will assume that we are in an IIS environment and proceed. // IIS uses the SCRIPT_NAME variable instead of a REQUEST_URI variable... thanks, MS - $uri .= $this->input->server->getString('SCRIPT_NAME'); + $scriptname = $this->input->server->getString('SCRIPT_NAME'); + if (substr($scriptname, 0, 1) !== '/' && substr($uri, -1) !== '/') { + $uri .= '/'; + } + $uri .= $scriptname; $queryHost = $this->input->server->getString('QUERY_STRING', ''); // If the QUERY_STRING variable exists append it to the URI string. From 872e959102f4aa551a59e0f96b576e16533001c8 Mon Sep 17 00:00:00 2001 From: Hannes Papenberg Date: Fri, 4 Jul 2025 18:15:16 +0200 Subject: [PATCH 2/4] Use str_starts_with/str_ends_with instead --- src/AbstractWebApplication.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AbstractWebApplication.php b/src/AbstractWebApplication.php index bfab4fbc..1ed2aad1 100644 --- a/src/AbstractWebApplication.php +++ b/src/AbstractWebApplication.php @@ -818,7 +818,7 @@ protected function detectRequestUri() // If not in "Apache Mode" we will assume that we are in an IIS environment and proceed. // IIS uses the SCRIPT_NAME variable instead of a REQUEST_URI variable... thanks, MS $scriptname = $this->input->server->getString('SCRIPT_NAME'); - if (substr($scriptname, 0, 1) !== '/' && substr($uri, -1) !== '/') { + if (!(str_starts_with($scriptname, '/') && str_ends_with($uri, '/'))) { $uri .= '/'; } $uri .= $scriptname; From c294a89a115d8edd6d053b95125814dd0d2ebb38 Mon Sep 17 00:00:00 2001 From: Hannes Papenberg Date: Fri, 4 Jul 2025 18:18:00 +0200 Subject: [PATCH 3/4] Reverting previous commit --- src/AbstractWebApplication.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AbstractWebApplication.php b/src/AbstractWebApplication.php index 1ed2aad1..bfab4fbc 100644 --- a/src/AbstractWebApplication.php +++ b/src/AbstractWebApplication.php @@ -818,7 +818,7 @@ protected function detectRequestUri() // If not in "Apache Mode" we will assume that we are in an IIS environment and proceed. // IIS uses the SCRIPT_NAME variable instead of a REQUEST_URI variable... thanks, MS $scriptname = $this->input->server->getString('SCRIPT_NAME'); - if (!(str_starts_with($scriptname, '/') && str_ends_with($uri, '/'))) { + if (substr($scriptname, 0, 1) !== '/' && substr($uri, -1) !== '/') { $uri .= '/'; } $uri .= $scriptname; From 3d99ac984a3743a45cbadb6003cb50b6f0eb4415 Mon Sep 17 00:00:00 2001 From: Hannes Papenberg Date: Fri, 4 Jul 2025 22:36:57 +0200 Subject: [PATCH 4/4] Use str_starts_with and str_ends_with properly --- src/AbstractWebApplication.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AbstractWebApplication.php b/src/AbstractWebApplication.php index bfab4fbc..911bcb25 100644 --- a/src/AbstractWebApplication.php +++ b/src/AbstractWebApplication.php @@ -818,7 +818,7 @@ protected function detectRequestUri() // If not in "Apache Mode" we will assume that we are in an IIS environment and proceed. // IIS uses the SCRIPT_NAME variable instead of a REQUEST_URI variable... thanks, MS $scriptname = $this->input->server->getString('SCRIPT_NAME'); - if (substr($scriptname, 0, 1) !== '/' && substr($uri, -1) !== '/') { + if (!str_starts_with($scriptname, '/') && !str_ends_with($uri, '/')) { $uri .= '/'; } $uri .= $scriptname;