Merge pull request #14077 from annando/idn

Fallback mechanism for missing IDN functions
This commit is contained in:
Tobias Diekershoff 2024-04-07 08:11:35 +02:00 committed by GitHub
commit ad65e56b16
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 58 additions and 32 deletions

View File

@ -30,7 +30,7 @@ Due to the large variety of operating systems and PHP platforms in existence we
* Apache with mod-rewrite enabled and "Options All" so you can use a local `.htaccess` file
* PHP 7.4+
* PHP *command line* access with register_argc_argv set to true in the php.ini file
* Curl, GD, GMP, PDO, mbstrings, MySQLi, hash, xml, zip, IntlChar and OpenSSL extensions
* Curl, GD, GMP, PDO, mbstrings, MySQLi, hash, xml, zip, IntlChar, IDN and OpenSSL extensions
* The POSIX module of PHP needs to be activated (e.g. [RHEL, CentOS](http://www.bigsoft.co.uk/blog/index.php/2014/12/08/posix-php-commands-not-working-under-centos-7) have disabled it)
* Some form of email server or email gateway such that PHP mail() works.
If you cannot set up your own email server, you can use the [phpmailer](https://github.com/friendica/friendica-addons/tree/develop/phpmailer) addon and use a remote SMTP server.

View File

@ -27,7 +27,7 @@ Requirements
* Apache mit einer aktiverten mod-rewrite-Funktion und dem Eintrag "Options All", so dass du die lokale .htaccess-Datei nutzen kannst
* PHP 7.4+
* PHP *Kommandozeilen*-Zugang mit register_argc_argv auf "true" gesetzt in der php.ini-Datei
* Curl, GD, GMP, PDO, mbstrings, MySQLi, hash, xml, zip, IntlChar and OpenSSL-Erweiterung
* Curl, GD, GMP, PDO, mbstrings, MySQLi, hash, xml, zip, IntlChar, IDN und OpenSSL-Erweiterung
* Das POSIX Modul muss aktiviert sein ([CentOS, RHEL](http://www.bigsoft.co.uk/blog/index.php/2014/12/08/posix-php-commands-not-working-under-centos-7http://www.bigsoft.co.uk/blog/index.php/2014/12/08/posix-php-commands-not-working-under-centos-7) haben dies z.B. deaktiviert)
* Einen E-Mail Server, so dass PHP `mail()` funktioniert.
Wenn kein eigener E-Mail Server zur Verfügung steht, kann alternativ das [phpmailer](https://github.com/friendica/friendica-addons/tree/develop/phpmailer) Addon mit einem externen SMTP Account verwendet werden.

View File

@ -495,6 +495,13 @@ class Installer
);
$returnVal = $returnVal ? $status : false;
$status = $this->checkFunction('idn_to_ascii',
DI::l10n()->t('IDN Functions PHP module'),
DI::l10n()->t('Error: IDN Functions PHP module required but not installed.'),
true
);
$returnVal = $returnVal ? $status : false;
return $returnVal;
}

View File

@ -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
*

View File

@ -110,6 +110,8 @@ class InstallerTest extends MockedTest
$this->mockL10nT('Error: File Information PHP module required but not installed.', 1);
$this->mockL10nT('GNU Multiple Precision PHP module', 1);
$this->mockL10nT('Error: GNU Multiple Precision PHP module required but not installed.', 1);
$this->mockL10nT('IDN Functions PHP module', 1);
$this->mockL10nT('Error: IDN Functions PHP module required but not installed.', 1);
$this->mockL10nT('Program execution functions', 1);
$this->mockL10nT('Error: Program execution functions (proc_open) required but not enabled.', 1);
}

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: 2024.06-dev\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-04-05 07:28+0000\n"
"POT-Creation-Date: 2024-04-06 11:09+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -2793,120 +2793,128 @@ msgstr ""
msgid "Error: GNU Multiple Precision PHP module required but not installed."
msgstr ""
#: src/Core/Installer.php:516
#: src/Core/Installer.php:499
msgid "IDN Functions PHP module"
msgstr ""
#: src/Core/Installer.php:500
msgid "Error: IDN Functions PHP module required but not installed."
msgstr ""
#: src/Core/Installer.php:523
msgid ""
"The web installer needs to be able to create a file called \"local.config.php"
"\" in the \"config\" folder of your web server and it is unable to do so."
msgstr ""
#: src/Core/Installer.php:517
#: src/Core/Installer.php:524
msgid ""
"This is most often a permission setting, as the web server may not be able "
"to write files in your folder - even if you can."
msgstr ""
#: src/Core/Installer.php:518
#: src/Core/Installer.php:525
msgid ""
"At the end of this procedure, we will give you a text to save in a file "
"named local.config.php in your Friendica \"config\" folder."
msgstr ""
#: src/Core/Installer.php:519
#: src/Core/Installer.php:526
msgid ""
"You can alternatively skip this procedure and perform a manual installation. "
"Please see the file \"doc/INSTALL.md\" for instructions."
msgstr ""
#: src/Core/Installer.php:522
#: src/Core/Installer.php:529
msgid "config/local.config.php is writable"
msgstr ""
#: src/Core/Installer.php:542
#: src/Core/Installer.php:549
msgid ""
"Friendica uses the Smarty3 template engine to render its web views. Smarty3 "
"compiles templates to PHP to speed up rendering."
msgstr ""
#: src/Core/Installer.php:543
#: src/Core/Installer.php:550
msgid ""
"In order to store these compiled templates, the web server needs to have "
"write access to the directory view/smarty3/ under the Friendica top level "
"folder."
msgstr ""
#: src/Core/Installer.php:544
#: src/Core/Installer.php:551
msgid ""
"Please ensure that the user that your web server runs as (e.g. www-data) has "
"write access to this folder."
msgstr ""
#: src/Core/Installer.php:545
#: src/Core/Installer.php:552
msgid ""
"Note: as a security measure, you should give the web server write access to "
"view/smarty3/ only--not the template files (.tpl) that it contains."
msgstr ""
#: src/Core/Installer.php:548
#: src/Core/Installer.php:555
msgid "view/smarty3 is writable"
msgstr ""
#: src/Core/Installer.php:576
#: src/Core/Installer.php:583
msgid ""
"Url rewrite in .htaccess seems not working. Make sure you copied .htaccess-"
"dist to .htaccess."
msgstr ""
#: src/Core/Installer.php:577
#: src/Core/Installer.php:584
msgid ""
"In some circumstances (like running inside containers), you can skip this "
"error."
msgstr ""
#: src/Core/Installer.php:579
#: src/Core/Installer.php:586
msgid "Error message from Curl when fetching"
msgstr ""
#: src/Core/Installer.php:585
#: src/Core/Installer.php:592
msgid "Url rewrite is working"
msgstr ""
#: src/Core/Installer.php:614
#: src/Core/Installer.php:621
msgid ""
"The detection of TLS to secure the communication between the browser and the "
"new Friendica server failed."
msgstr ""
#: src/Core/Installer.php:615
#: src/Core/Installer.php:622
msgid ""
"It is highly encouraged to use Friendica only over a secure connection as "
"sensitive information like passwords will be transmitted."
msgstr ""
#: src/Core/Installer.php:616
#: src/Core/Installer.php:623
msgid "Please ensure that the connection to the server is secure."
msgstr ""
#: src/Core/Installer.php:617
#: src/Core/Installer.php:624
msgid "No TLS detected"
msgstr ""
#: src/Core/Installer.php:619
#: src/Core/Installer.php:626
msgid "TLS detected"
msgstr ""
#: src/Core/Installer.php:636
#: src/Core/Installer.php:643
msgid "ImageMagick PHP extension is not installed"
msgstr ""
#: src/Core/Installer.php:638
#: src/Core/Installer.php:645
msgid "ImageMagick PHP extension is installed"
msgstr ""
#: src/Core/Installer.php:659
#: src/Core/Installer.php:666
msgid "Database already in use."
msgstr ""
#: src/Core/Installer.php:664
#: src/Core/Installer.php:671
msgid "Could not connect to database."
msgstr ""
@ -6656,9 +6664,9 @@ msgstr[1] ""
#: src/Module/Debug/ItemBody.php:38 src/Module/Diaspora/Receive.php:57
#: src/Module/Item/Display.php:96 src/Module/Item/Feed.php:59
#: src/Module/Item/Follow.php:41 src/Module/Item/Ignore.php:41
#: src/Module/Item/Pin.php:41 src/Module/Item/Pin.php:56
#: src/Module/Item/Searchtext.php:53 src/Module/Item/Star.php:42
#: src/Module/Update/Display.php:37
#: src/Module/Item/Language.php:53 src/Module/Item/Pin.php:41
#: src/Module/Item/Pin.php:56 src/Module/Item/Searchtext.php:53
#: src/Module/Item/Star.php:42 src/Module/Update/Display.php:37
msgid "Access denied."
msgstr ""