Commit 47cdc194 authored by Martin Kutschker's avatar Martin Kutschker Committed by Christian Kuhn
Browse files

[TASK] Remove obsolete compatibility method HttpUtility::idn_to_ascii()

Since PHP 7.4 the core can use the Intl function directly.

Resolves: #93900
Releases: master
Change-Id: I2428fc9765bec2cd39f458febfe5d59231925d53
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/68759


Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Tested-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent c26dbb33
......@@ -23,7 +23,6 @@ use Symfony\Component\Routing\RouteCollection as SymfonyRouteCollection;
use TYPO3\CMS\Backend\Routing\Exception\MethodNotAllowedException;
use TYPO3\CMS\Backend\Routing\Exception\ResourceNotFoundException;
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\HttpUtility;
/**
* Implementation of a class for adding routes, collecting throughout the Bootstrap
......@@ -123,7 +122,7 @@ class Router implements SingletonInterface
$context = new RequestContext(
$path,
$request->getMethod(),
(string)HttpUtility::idn_to_ascii($request->getUri()->getHost()),
(string)idn_to_ascii($request->getUri()->getHost()),
$request->getUri()->getScheme()
);
try {
......
......@@ -62,7 +62,6 @@ use TYPO3\CMS\Core\Type\Bitmask\Permission;
use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\HttpUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Core\Utility\StringUtility;
use TYPO3\CMS\Core\Versioning\VersionState;
......@@ -2609,7 +2608,7 @@ class DataHandler implements LoggerAwareInterface
break;
case 'domainname':
if (!preg_match('/^[a-z0-9.\\-]*$/i', $value)) {
$value = (string)HttpUtility::idn_to_ascii($value);
$value = (string)idn_to_ascii($value);
}
break;
case 'email':
......
......@@ -30,7 +30,6 @@ use TYPO3\CMS\Core\Site\Entity\SiteInterface;
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
use TYPO3\CMS\Core\Site\SiteFinder;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\HttpUtility;
use TYPO3\CMS\Core\Utility\RootlineUtility;
/**
......@@ -125,7 +124,7 @@ class SiteMatcher implements SingletonInterface
$context = new RequestContext(
'',
$request->getMethod(),
(string)HttpUtility::idn_to_ascii($request->getUri()->getHost()),
(string)idn_to_ascii($request->getUri()->getHost()),
$request->getUri()->getScheme(),
// Ports are only necessary for URL generation in Symfony which is not used by TYPO3
80,
......@@ -202,7 +201,7 @@ class SiteMatcher implements SingletonInterface
['site' => $site, 'language' => $siteLanguage, 'tail' => ''],
array_filter(['tail' => '.*', 'port' => (string)$uri->getPort()]),
['utf8' => true],
(string)(HttpUtility::idn_to_ascii($uri->getHost()) ?: ''),
(string)idn_to_ascii($uri->getHost()),
$uri->getScheme()
);
$identifier = 'site_' . $site->getIdentifier() . '_' . $siteLanguage->getLanguageId();
......
......@@ -900,7 +900,7 @@ class GeneralUtility
return false;
}
if (isset($parsedUrl['host']) && !preg_match('/^[a-z0-9.\\-]*$/i', $parsedUrl['host'])) {
$host = HttpUtility::idn_to_ascii($parsedUrl['host']);
$host = (string)idn_to_ascii($parsedUrl['host']);
if ($host === false) {
return false;
}
......
......@@ -15,8 +15,6 @@
namespace TYPO3\CMS\Core\Utility;
use Symfony\Polyfill\Intl\Idn\Idn;
/**
* HTTP Utility class
*/
......@@ -181,30 +179,4 @@ class HttpUtility
return $queryString && $prependCharacter ? $prependCharacter . $queryString : $queryString;
}
/**
* Compatibility layer for PHP versions running ICU 4.4, as the constant INTL_IDNA_VARIANT_UTS46
* is only available as of ICU 4.6.
*
* Please note: Once PHP 7.4 is the minimum requirement, this method will vanish without further notice
* as it is recommended to use the native method instead, when working against a clean environment.
*
* @param string $domain the domain name to convert Punicode to ASCII.
* @return string|bool
*/
public static function idn_to_ascii(string $domain)
{
if (defined('INTL_IDNA_VARIANT_UTS46') && !defined('TYPO3_IDN_TO_ASCII_USE_COMPAT')) {
return idn_to_ascii($domain, IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46);
}
// 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 Idn::idn_to_ascii($domain, IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46, $result);
}
}
......@@ -297,7 +297,7 @@ class ExternalLinktype extends AbstractLinktype
$parts = parse_url($url);
if ($parts['host'] ?? false) {
try {
$newDomain = (string)HttpUtility::idn_to_ascii($parts['host']);
$newDomain = (string)idn_to_ascii($parts['host']);
if (strcmp($parts['host'], $newDomain) !== 0) {
$parts['host'] = $newDomain;
$url = HttpUtility::buildUrl($parts);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment