From dd9c011fdd7cc82d25ab84a29c30186586090724 Mon Sep 17 00:00:00 2001 From: camer0n Date: Thu, 28 Sep 2023 09:36:31 -0700 Subject: [PATCH] Closes #4804 - Conversion of diacritics in name2id() --- e107_handlers/form_handler.php | 3 ++- e107_tests/tests/unit/e_formTest.php | 10 +++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index 16dd21cb5..53b062f43 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -4374,7 +4374,8 @@ var_dump($select_options);*/ public function name2id($name) { $name = strtolower($name); - return rtrim(str_replace(array('[]', '[', ']', '_', '/', ' ','.', '(', ')', '::', ':', '?','=',"'"), array('-', '-', '', '-', '-', '-', '-','','','-','','-','-',''), $name), '-'); + $name = $this->tp->toASCII($name); + return rtrim(str_replace(array('[]', '[', ']', '_', '/', ' ','.', '(', ')', '::', ':', '?','=',"'",','), array('-', '-', '', '-', '-', '-', '-','','','-','','-','-','',''), $name), '-'); } /** diff --git a/e107_tests/tests/unit/e_formTest.php b/e107_tests/tests/unit/e_formTest.php index e79105269..68108c670 100644 --- a/e107_tests/tests/unit/e_formTest.php +++ b/e107_tests/tests/unit/e_formTest.php @@ -1041,6 +1041,14 @@ class e_formTest extends \Codeception\Test\Unit $result = $this->_frm->name2id($text); $this->assertEquals($expected, $result); + + // Test with diacritics + $text = "Façade, Jalapeño, Frappé"; + $expected = 'facade-jalapeno-frappe'; + + $result = $this->_frm->name2id($text); + $this->assertEquals($expected, $result); + } /* public function testFormat_options() @@ -1100,7 +1108,7 @@ class e_formTest extends \Codeception\Test\Unit 'number_001' => 555, 'number_002' => "444", - 'bool_001' => ADMIN_TRUE_ICON, + 'bool_001' => constant('ADMIN_TRUE_ICON'), 'bool_002' => "", 'dropdown_001' => 'Label 2',