From d43d4b7b3455b9c282202348b2235908fcd96c5e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Noack?= <noack@data-quest.de>
Date: Mon, 6 Jan 2025 12:43:28 +0000
Subject: [PATCH] =?UTF-8?q?Resolve=20#5096=20"Klick=20auf=20neue=20Ank?=
 =?UTF-8?q?=C3=BCndigung=20f=C3=BChrt=20zu=20Exception:=20Default=20contro?=
 =?UTF-8?q?ller=20'default'=20not=20found'"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #5096

Merge request studip/studip!3809
---
 app/controllers/course/go.php | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/app/controllers/course/go.php b/app/controllers/course/go.php
index 400c44a4c84..83569133b0c 100644
--- a/app/controllers/course/go.php
+++ b/app/controllers/course/go.php
@@ -46,13 +46,16 @@ class Course_GoController extends AuthenticatedController
 
         // gibt es eine Anweisung zur Umleitung?
         $redirect_to = Request::get('redirect_to');
-        if ($redirect_to) {
+        if (
+            $redirect_to
+            && !(
+                str_starts_with($redirect_to, '#')
+                || str_starts_with($redirect_to, '?')
+            )
+        ) {
             if (!is_internal_url($redirect_to)) {
                 throw new Exception('Invalid redirection');
             }
-            if (str_starts_with($redirect_to, '#')) {
-                $redirect_to = 'dispatch.php/course/go' . $redirect_to;
-            }
             $this->redirect(URLHelper::getURL($redirect_to, ['cid' => $course_id]));
             return;
         }
@@ -62,7 +65,7 @@ class Course_GoController extends AuthenticatedController
         if (Navigation::hasItem("/course")) {
             foreach (Navigation::getItem("/course")->getSubNavigation() as $index => $navigation) {
                 if ($index !== 'admin') {
-                    $this->redirect(URLHelper::getURL($navigation->getURL()));
+                    $this->redirect(URLHelper::getURL($navigation->getURL() . $redirect_to));
                     return;
                 }
             }
-- 
GitLab