[BUGFIX] Ensure no PHP warning is thrown if legacy code is used 44/60844/2
authorBenni Mack <benni@typo3.org>
Wed, 29 May 2019 21:28:56 +0000 (23:28 +0200)
committerBenni Mack <benni@typo3.org>
Wed, 5 Jun 2019 11:39:47 +0000 (13:39 +0200)
When no constant is given (due to old OS),
a PHP warning is now triggered due to PHP 7.2. This is
overcome to use the polyfill functionality instead then.

Resolves: #88443
Releases: master, 9.5
Change-Id: I5ac673f10bc1421e543b8f969a0111e9bbc9c11e
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/60844
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Michael Waack <m.waack@i-d.de>
Tested-by: Thomas Anders <me@naderio.de>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Michael Waack <m.waack@i-d.de>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Reviewed-by: Thomas Anders <me@naderio.de>
Reviewed-by: Benni Mack <benni@typo3.org>
typo3/sysext/core/Classes/Utility/HttpUtility.php

index d6bef01..cde8181 100644 (file)
@@ -191,9 +191,17 @@ class HttpUtility
      */
     public static function idn_to_ascii(string $domain)
     {
-        if (defined('INTL_IDNA_VARIANT_UTS46')) {
+        if (defined('INTL_IDNA_VARIANT_UTS46') && !defined('TYPO3_IDN_TO_ASCII_USE_COMPAT')) {
             return idn_to_ascii($domain, IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46);
         }
-        return idn_to_ascii($domain);
+        // This is done due to some heavy old systems where native functionality is there, but does not support UTS46 yet.
+        if (!defined('TYPO3_IDN_TO_ASCII_USE_COMPAT')) {
+            define('TYPO3_IDN_TO_ASCII_USE_COMPAT', true);
+        }
+        if (!defined('INTL_IDNA_VARIANT_UTS46')) {
+            define('INTL_IDNA_VARIANT_UTS46', 1);
+        }
+        $result = [];
+        return \Symfony\Polyfill\Intl\Idn\Idn::idn_to_ascii($domain, IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46, $result);
     }
 }