From 584f83db83072a1ec83a18cab7810515c52128a1 Mon Sep 17 00:00:00 2001
From: Christian Kuhn <lolli@schwarzbu.ch>
Date: Sat, 10 Aug 2024 14:10:16 +0200
Subject: [PATCH] [TASK] Sanitize idn_to_ascii with empty string
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

idn_to_ascii() must not be called with empty
string in PHP 8.4.

Resolves: #104587
Related: #104513
Releases: main, 12.4, 11.5
Change-Id: I649d157cca3dadbe237e20eb440b071a1885db71
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/85581
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Jasmina Ließmann <minapokhalo+typo3@gmail.com>
Tested-by: Jasmina Ließmann <minapokhalo+typo3@gmail.com>
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/85583
---
 typo3/sysext/core/Classes/Routing/SiteMatcher.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/typo3/sysext/core/Classes/Routing/SiteMatcher.php b/typo3/sysext/core/Classes/Routing/SiteMatcher.php
index c8f298249e3a..137c4ab75c72 100644
--- a/typo3/sysext/core/Classes/Routing/SiteMatcher.php
+++ b/typo3/sysext/core/Classes/Routing/SiteMatcher.php
@@ -245,7 +245,7 @@ class SiteMatcher implements SingletonInterface
         $requestContext = new RequestContext(
             '',
             $request->getMethod(),
-            (string)idn_to_ascii($uri->getHost()),
+            $uri->getHost() ? (string)idn_to_ascii($uri->getHost()) : '',
             $uri->getScheme(),
             // Ports are only necessary for URL generation in Symfony which is not used by TYPO3
             80,
-- 
GitLab