From b333f3fa1ea4d661db10e88325152eb2ef5437f3 Mon Sep 17 00:00:00 2001
From: Jan-Hendrik Willms <tleilax+studip@gmail.com>
Date: Tue, 21 Jun 2022 08:39:09 +0000
Subject: [PATCH] fix path handling in `action_link()`, fixes #1188

Closes #1188

Merge request studip/studip!704
---
 app/controllers/studip_controller.php           | 5 +----
 tests/unit/lib/classes/StudipControllerTest.php | 6 ++++++
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/app/controllers/studip_controller.php b/app/controllers/studip_controller.php
index a08a9463c38..e0511556256 100644
--- a/app/controllers/studip_controller.php
+++ b/app/controllers/studip_controller.php
@@ -740,10 +740,7 @@ abstract class StudipController extends Trails_Controller
      */
     public function action_link($action)
     {
-        $arguments = func_get_args();
-        array_unshift($arguments, $this->controller_path());
-
-        return $this->link_for(...$arguments);
+        return htmlReady($this->action_url(...func_get_args()));
     }
 
     /**
diff --git a/tests/unit/lib/classes/StudipControllerTest.php b/tests/unit/lib/classes/StudipControllerTest.php
index a7009fe2aa5..532116677ae 100644
--- a/tests/unit/lib/classes/StudipControllerTest.php
+++ b/tests/unit/lib/classes/StudipControllerTest.php
@@ -76,6 +76,12 @@ final class StudipControllerTest extends Codeception\Test\Unit
             $expected,
             $this->getRelativeURL($url)
         );
+
+        $link = $this->getController()->action_link(...$args);
+        $this->assertEquals(
+            htmlspecialchars($expected),
+            $this->getRelativeURL($link)
+        );
     }
 
     /**
-- 
GitLab