From 25900d38bd3ab098069b272c2b73227fa61e0759 Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Tue, 21 Dec 2021 12:46:02 +0000 Subject: [PATCH] [UTIL][EXCEPTION][RedirectException] Remove hack that would attempt to generate a URL inplace --- src/Util/Exception/RedirectException.php | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/Util/Exception/RedirectException.php b/src/Util/Exception/RedirectException.php index 7fa1c76444..b28e4cd827 100644 --- a/src/Util/Exception/RedirectException.php +++ b/src/Util/Exception/RedirectException.php @@ -39,15 +39,11 @@ class RedirectException extends Exception public function __construct(string $route_id_or_path = '', array $params = [], string $message = '', int $code = 302, ?string $url = null, bool $allow_open_redirect = false, ?Exception $previous_exception = null) { if (!empty($route_id_or_path) || !empty($url)) { - if ($route_id_or_path[0] === '/') { - $url = "https://{$_ENV['SOCIAL_DOMAIN']}{$route_id_or_path}"; - } else { - $url ??= Router::url($route_id_or_path, $params, Router::ABSOLUTE_PATH); // Absolute path doesn't include host - if (!$allow_open_redirect) { - if (Router::isAbsolute($url)) { - Log::warning("A RedirectException that shouldn't allow open redirects attempted to redirect to {$url}"); - throw new ServerException(_m('Can not redirect to outside the website from here'), 5400); // 500 Internal server error (likely a bug) - } + $url ??= Router::url($route_id_or_path, $params, Router::ABSOLUTE_PATH); // Absolute path doesn't include host + if (!$allow_open_redirect) { + if (Router::isAbsolute($url)) { + Log::warning("A RedirectException that shouldn't allow open redirects attempted to redirect to {$url}"); + throw new ServerException(_m('Can not redirect to outside the website from here'), 5400); // 500 Internal server error (likely a bug) } } $this->redirect_response = new RedirectResponse($url);