mirror of
https://github.com/friendica/friendica
synced 2025-05-05 17:04:11 +02:00
Fallback mechanism for missing IDN functions
This commit is contained in:
parent
e9dcf15d86
commit
78dc61b59e
6 changed files with 58 additions and 32 deletions
|
@ -533,20 +533,29 @@ class Network
|
|||
{
|
||||
$parts = parse_url($uri);
|
||||
if (!empty($parts['scheme']) && !empty($parts['host'])) {
|
||||
$parts['host'] = idn_to_ascii($parts['host']);
|
||||
$parts['host'] = self::idnToAscii($parts['host']);
|
||||
$uri = (string)Uri::fromParts($parts);
|
||||
} else {
|
||||
$parts = explode('@', $uri);
|
||||
if (count($parts) == 2) {
|
||||
$uri = $parts[0] . '@' . idn_to_ascii($parts[1]);
|
||||
$uri = $parts[0] . '@' . self::idnToAscii($parts[1]);
|
||||
} else {
|
||||
$uri = idn_to_ascii($uri);
|
||||
$uri = self::idnToAscii($uri);
|
||||
}
|
||||
}
|
||||
|
||||
return $uri;
|
||||
}
|
||||
|
||||
private static function idnToAscii(string $uri): string
|
||||
{
|
||||
if (!function_exists('idn_to_ascii')) {
|
||||
Logger::error('IDN functions are missing.');
|
||||
return $uri;
|
||||
}
|
||||
return idn_to_ascii($uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Switch the scheme of an url between http and https
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue