Skip to content

Commit

Permalink
Closes #4804 - Conversion of diacritics in name2id()
Browse files Browse the repository at this point in the history
  • Loading branch information
CaMer0n committed Sep 28, 2023
1 parent 720ea0c commit dd9c011
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion e107_handlers/form_handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -4374,7 +4374,8 @@ protected function _format_id($id_value, $name, $value = null, $return_attribute
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), '-');
}

/**
Expand Down
10 changes: 9 additions & 1 deletion e107_tests/tests/unit/e_formTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,14 @@ public function testName2id()
$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()
Expand Down Expand Up @@ -1100,7 +1108,7 @@ public function testRenderValue()
'number_001' => 555,
'number_002' => "<a class='e-tip e-editable editable-click' data-name='number_002' title=\"Edit Number 002\" data-type='text' data-pk='0' data-url='".e_SELF."?mode=&action=inline&id=0&ajax_used=1' href='#'>444</a>",

'bool_001' => ADMIN_TRUE_ICON,
'bool_001' => constant('ADMIN_TRUE_ICON'),
'bool_002' => "<a class='e-tip e-editable editable-click e-editable-boolean' data-name='bool_002' data-source='{\"0\":\"\u0026cross;\",\"1\":\"\u0026check;\"}' title=\"Edit Bool 002\" data-type='select' data-inputclass='x-editable-bool-002 e-editable-boolean' data-value=\"1\" href='#' data-class='e-editable-boolean' data-url='".e_SELF."?mode=&amp;action=inline&amp;id=0&amp;ajax_used=1'>&check;</a>",

'dropdown_001' => 'Label 2',
Expand Down

0 comments on commit dd9c011

Please sign in to comment.