Skip to content

EspoCRM – Open Source CRM Application

Portal with non-default id: password-reset link causes infinite 301 redirect loop that doubles the query string (414 Request-URI Too Long) (#3645)

Andrew Fontana9bfad2ede42d
diff --git a/application/Espo/Core/Portal/Utils/Url.php b/application/Espo/Core/Portal/Utils/Url.php
index f4fff4d7e6..b4dd2ab806 100644
--- a/application/Espo/Core/Portal/Utils/Url.php
+++ b/application/Espo/Core/Portal/Utils/Url.php
@@ -141,18 +141,19 @@ class Url
public static function getRedirectUrlWithTrailingSlash(): ?string
{
- $uri = $_SERVER['REQUEST_URI'];
+ $uri = $_SERVER['REQUEST_URI'] ?? '';
+ $path = explode('?', $uri, 2)[0];
- if ($uri === '' || $uri === '/' || str_ends_with($uri, '/')) {
+ if ($path === '' || $path === '/' || str_ends_with($path, '/')) {
return null;
}
- $output = $uri . '/';
+ $output = $path . '/';
$queryString = $_SERVER['QUERY_STRING'] ?? null;
if ($queryString !== null && $queryString !== '') {
- $output .= '?' . $_SERVER['QUERY_STRING'];
+ $output .= '?' . $queryString;
}
return $output;