From 9e322d25659650067e7ad346619cc5f01ceff80f Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Tue, 23 Oct 2018 12:14:17 +0200 Subject: [PATCH 1/2] Fixing absolute/relative path --- mod/toggle_mobile.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod/toggle_mobile.php b/mod/toggle_mobile.php index ad77dd1ccd..388c40891a 100644 --- a/mod/toggle_mobile.php +++ b/mod/toggle_mobile.php @@ -17,5 +17,5 @@ function toggle_mobile_init(App $a) { $address = ''; } - $a->internalRedirect($address); + System::externalRedirect($address); } From 3e6ea9383b1190bccb440e6a2b710f263fdd468b Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Tue, 23 Oct 2018 12:17:41 +0200 Subject: [PATCH 2/2] Making redirect message more informative --- src/App.php | 2 +- src/Core/System.php | 2 +- tests/src/Core/SystemTest.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/App.php b/src/App.php index 8cd3b74f99..0ba8207798 100644 --- a/src/App.php +++ b/src/App.php @@ -2000,7 +2000,7 @@ class App public function internalRedirect($toUrl = '', $ssl = false) { if (filter_var($toUrl, FILTER_VALIDATE_URL)) { - throw new InternalServerErrorException('URL is not a relative path, please use System::externalRedirectTo'); + throw new InternalServerErrorException("'$toUrl is not a relative path, please use System::externalRedirectTo"); } $redirectTo = $this->getBaseURL($ssl) . '/' . ltrim($toUrl, '/'); diff --git a/src/Core/System.php b/src/Core/System.php index e071866ee9..6079d9e228 100644 --- a/src/Core/System.php +++ b/src/Core/System.php @@ -247,7 +247,7 @@ class System extends BaseObject public static function externalRedirect($url) { if (!filter_var($url, FILTER_VALIDATE_URL)) { - throw new InternalServerErrorException('URL is not a fully qualified URL, please use App->internalRedirect() instead'); + throw new InternalServerErrorException("'$url' is not a fully qualified URL, please use App->internalRedirect() instead"); } header("Location: $url"); diff --git a/tests/src/Core/SystemTest.php b/tests/src/Core/SystemTest.php index b85bce44cb..6b0781198a 100644 --- a/tests/src/Core/SystemTest.php +++ b/tests/src/Core/SystemTest.php @@ -34,4 +34,4 @@ class SystemTest extends TestCase $guid = System::createGUID(23, 'test'); $this->assertGuid($guid, 23, 'test'); } -} \ No newline at end of file +}