From eba0ff339b340ba4623fa9c44117f729d8a6ffed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Thu, 1 Feb 2024 09:52:37 +0100 Subject: [PATCH 1/3] Allow application to pass external links in navigation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- core/Controller/NavigationController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/Controller/NavigationController.php b/core/Controller/NavigationController.php index db1d67cc77843..61f8fe1d5e788 100644 --- a/core/Controller/NavigationController.php +++ b/core/Controller/NavigationController.php @@ -115,10 +115,10 @@ private function generateETag(array $navigation): string { */ private function rewriteToAbsoluteUrls(array $navigation): array { foreach ($navigation as &$entry) { - if (!str_starts_with($entry['href'], $this->urlGenerator->getBaseUrl())) { + if (!str_starts_with($entry['href'], 'https://') && !str_starts_with($entry['href'], 'http://')) { $entry['href'] = $this->urlGenerator->getAbsoluteURL($entry['href']); } - if (!str_starts_with($entry['icon'], $this->urlGenerator->getBaseUrl())) { + if (!str_starts_with($entry['icon'], 'https://') && !str_starts_with($entry['icon'], 'http://')) { $entry['icon'] = $this->urlGenerator->getAbsoluteURL($entry['icon']); } } From ce808eefb5f5528542e2cc4c65ab1dcdabdf03b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Thu, 1 Feb 2024 10:15:45 +0100 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20Revert=20external=20url=20support=20?= =?UTF-8?q?in=20icon=20as=20it=E2=80=99s=20not=20allowed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- core/Controller/NavigationController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/Controller/NavigationController.php b/core/Controller/NavigationController.php index 61f8fe1d5e788..2432df937ce48 100644 --- a/core/Controller/NavigationController.php +++ b/core/Controller/NavigationController.php @@ -118,7 +118,7 @@ private function rewriteToAbsoluteUrls(array $navigation): array { if (!str_starts_with($entry['href'], 'https://') && !str_starts_with($entry['href'], 'http://')) { $entry['href'] = $this->urlGenerator->getAbsoluteURL($entry['href']); } - if (!str_starts_with($entry['icon'], 'https://') && !str_starts_with($entry['icon'], 'http://')) { + if (!str_starts_with($entry['icon'], $this->urlGenerator->getBaseUrl())) { $entry['icon'] = $this->urlGenerator->getAbsoluteURL($entry['icon']); } } From 4cf140b5e5f20d384ff5ddea88eb030a791ca21c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Thu, 1 Feb 2024 14:29:51 +0100 Subject: [PATCH 3/3] fix: Support other schemes than HTTP and HTTPS in app navigation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- core/Controller/NavigationController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/Controller/NavigationController.php b/core/Controller/NavigationController.php index 2432df937ce48..0996b41042ed5 100644 --- a/core/Controller/NavigationController.php +++ b/core/Controller/NavigationController.php @@ -115,7 +115,8 @@ private function generateETag(array $navigation): string { */ private function rewriteToAbsoluteUrls(array $navigation): array { foreach ($navigation as &$entry) { - if (!str_starts_with($entry['href'], 'https://') && !str_starts_with($entry['href'], 'http://')) { + /* If parse_url finds no host it means the URL is not absolute */ + if (!isset(\parse_url($entry['href'])['host'])) { $entry['href'] = $this->urlGenerator->getAbsoluteURL($entry['href']); } if (!str_starts_with($entry['icon'], $this->urlGenerator->getBaseUrl())) {