From b6875fa0b46ff6ab872ff8bc2e7dc3800a7d532f Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Wed, 2 Apr 2025 17:45:31 +0100 Subject: [PATCH 1/2] Revert "[5.x] Escape start_page Preference to avoid invalid Redirect (#11616)" This reverts commit b4b78754a5b1eb73f7eb31dd525427a2476ddcae. --- src/Http/Controllers/CP/StartPageController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Http/Controllers/CP/StartPageController.php b/src/Http/Controllers/CP/StartPageController.php index e6ac7ceafa..918587c30c 100644 --- a/src/Http/Controllers/CP/StartPageController.php +++ b/src/Http/Controllers/CP/StartPageController.php @@ -10,7 +10,7 @@ public function __invoke() { session()->reflash(); - $url = config('statamic.cp.route').'/'.urlencode(Preference::get('start_page', config('statamic.cp.start_page'))); + $url = config('statamic.cp.route').'/'.Preference::get('start_page', config('statamic.cp.start_page')); return redirect($url); } From a911b0819891f1fe6a2bb7dd54810daac898486c Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Wed, 2 Apr 2025 18:03:42 +0100 Subject: [PATCH 2/2] Add test --- tests/CP/StartPageTest.php | 46 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 tests/CP/StartPageTest.php diff --git a/tests/CP/StartPageTest.php b/tests/CP/StartPageTest.php new file mode 100644 index 0000000000..45d1cee3f8 --- /dev/null +++ b/tests/CP/StartPageTest.php @@ -0,0 +1,46 @@ +setPreference('start_page', 'collections/pages')->save(); + + $this + ->actingAs(User::make()->makeSuper()->save()) + ->get('/cp') + ->assertRedirect('/cp/collections/pages'); + } + + #[Test] + public function it_falls_back_to_start_page_config_option_when_preference_is_missing() + { + config('statamic.cp.start_page', 'dashboard'); + + $this + ->actingAs(User::make()->makeSuper()->save()) + ->get('/cp') + ->assertRedirect('/cp/dashboard'); + } +}