mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-02 04:37:42 +08:00
Fixes #16648: Html::strtolower() was corrupting UTF-8 strings
This commit is contained in:
committed by
Alexander Makarov
parent
383953d9b7
commit
06227c7075
@ -4,6 +4,7 @@ Yii Framework 2 Change Log
|
||||
2.0.16 under development
|
||||
------------------------
|
||||
|
||||
- Bug #16648: Html::strtolower() was corrupting UTF-8 strings (Kolyunya)
|
||||
- Bug #13977: Skip validation if file input does not exist (RobinKamps, s1lver)
|
||||
- Bug #16183: Fixed when `yii\helpers\BaseFileHelper` sometimes returned wrong value (samdark, SilverFire, OndrejVasicek)
|
||||
- Bug #13932: Fix number validator attributes comparison (uaoleg, s1lver)
|
||||
|
||||
@ -2295,7 +2295,8 @@ class BaseHtml
|
||||
*/
|
||||
public static function getInputId($model, $attribute)
|
||||
{
|
||||
$name = strtolower(static::getInputName($model, $attribute));
|
||||
$charset = Yii::$app ? Yii::$app->charset : 'UTF-8';
|
||||
$name = mb_strtolower(static::getInputName($model, $attribute), $charset);
|
||||
return str_replace(['[]', '][', '[', ']', ' ', '.'], ['', '-', '-', '', '-', '-'], $name);
|
||||
}
|
||||
|
||||
|
||||
@ -1778,6 +1778,19 @@ EOD;
|
||||
$this->assertSame($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider testGetInputIdDataProvider
|
||||
*/
|
||||
public function testGetInputId($attributeName, $inputIdExpected)
|
||||
{
|
||||
$model = new DynamicModel();
|
||||
$model->defineAttribute($attributeName);
|
||||
|
||||
$inputIdActual = Html::getInputId($model, $attributeName);
|
||||
|
||||
$this->assertSame($inputIdExpected, $inputIdActual);
|
||||
}
|
||||
|
||||
public function testEscapeJsRegularExpression()
|
||||
{
|
||||
$expected = '/[a-z0-9-]+/';
|
||||
@ -1858,6 +1871,45 @@ HTML;
|
||||
|
||||
$this->assertContains('placeholder="My placeholder: Name"', $html);
|
||||
}
|
||||
|
||||
public function testGetInputIdDataProvider()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'foo',
|
||||
'dynamicmodel-foo',
|
||||
],
|
||||
[
|
||||
'FooBar',
|
||||
'dynamicmodel-foobar',
|
||||
],
|
||||
[
|
||||
'Foo_Bar',
|
||||
'dynamicmodel-foo_bar',
|
||||
],
|
||||
[
|
||||
'foo[]',
|
||||
'dynamicmodel-foo',
|
||||
],
|
||||
[
|
||||
'foo[bar][baz]',
|
||||
'dynamicmodel-foo-bar-baz',
|
||||
],
|
||||
|
||||
[
|
||||
'foo.bar',
|
||||
'dynamicmodel-foo-bar',
|
||||
],
|
||||
[
|
||||
'bild_groß_dateiname',
|
||||
'dynamicmodel-bild_groß_dateiname',
|
||||
],
|
||||
[
|
||||
'ФуБарБаз',
|
||||
'dynamicmodel-фубарбаз',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user