diff --git a/composer.json b/composer.json index d2a79e4405fd..42951adb6ed2 100644 --- a/composer.json +++ b/composer.json @@ -19,6 +19,7 @@ "ext-gd": "*", "ext-zlib": "*", "ext-curl": "*", + "ext-intl": "*", "iamcal/lib_autolink": "~1.7", "phpmailer/phpmailer": "~6.0", "sabre/vobject": "~4.1", diff --git a/inc/config.class.php b/inc/config.class.php index 06089ed7c4ed..4316754f71bf 100644 --- a/inc/config.class.php +++ b/inc/config.class.php @@ -2413,6 +2413,9 @@ static function checkExtensions($list = null) { 'CAS' => [ 'required' => false, 'class' => 'phpCAS' + ], + 'intl' => [ + 'required' => true ] ]; } else { diff --git a/inc/toolbox.class.php b/inc/toolbox.class.php index cb064b0d3ca9..78896e58e27f 100644 --- a/inc/toolbox.class.php +++ b/inc/toolbox.class.php @@ -2654,6 +2654,7 @@ public static function removeHtmlSpecialChars($string) { * @return string */ public static function slugify($string) { + $string = transliterator_transliterate("Any-Latin; NFD; [:Nonspacing Mark:] Remove; NFC; [:Punctuation:] Remove; Lower();", $string); $string = str_replace(' ', '-', self::strtolower($string, 'UTF-8')); $string = self::removeHtmlSpecialChars($string); $string = preg_replace('~[^0-9a-z]+~i', '-', $string); diff --git a/tests/units/Toolbox.php b/tests/units/Toolbox.php index a87bc82b5b41..9f7f122bb104 100644 --- a/tests/units/Toolbox.php +++ b/tests/units/Toolbox.php @@ -53,18 +53,24 @@ public function testRemoveHtmlSpecialChars() { $this->string($result)->isIdenticalTo($expected); } - public function testSlugify() { - $original = 'My - string èé Ê À ß'; - $expected = 'my-string-ee-e-a-sz'; - $result = \Toolbox::slugify($original); - - $this->string($result)->isIdenticalTo($expected); + protected function slugifyProvider() { + return [ + [ + 'string' => 'My - string èé Ê À ß', + 'expcected' => 'my-string-ee-e-a-sz' + ], [ + //https://github.com/glpi-project/glpi/issues/2946 + 'string' => 'Έρευνα ικανοποίησης - Αιτήματα', + 'expcected' => 'ereuna-ikanopoieses-aitemata' + ] + ]; + } - //https://github.com/glpi-project/glpi/issues/2946 - $original = 'Έρευνα ικανοποίησης - Αιτήματα'; //el_GR - $result = \Toolbox::slugify($original); - $this->string($result)->startWith('nok_') - ->length->isIdenticalTo(10 + strlen('nok_')); + /** + * @dataProvider slugifyProvider + */ + public function testSlugify($string, $expected) { + $this->string(\Toolbox::slugify($string))->isIdenticalTo($expected); } public function dataGetSize() {