mirror of
https://github.com/yiisoft/yii.git
synced 2026-03-07 00:26:52 +01:00
Better CStringValidator encoding handling if application charset was not set
This commit is contained in:
@@ -69,9 +69,17 @@ class CStringValidator extends CValidator
|
||||
return;
|
||||
|
||||
if(function_exists('mb_strlen') && $this->encoding!==false)
|
||||
$length=mb_strlen($value,$this->encoding ? $this->encoding : Yii::app()->charset);
|
||||
{
|
||||
if(!empty($this->encoding))
|
||||
mb_strlen($value, $this->encoding);
|
||||
else if(!empty(Yii::app()->charset))
|
||||
$length=mb_strlen($value, Yii::app()->charset);
|
||||
else
|
||||
$length=strlen($value);
|
||||
}
|
||||
else
|
||||
$length=strlen($value);
|
||||
|
||||
if($this->min!==null && $length<$this->min)
|
||||
{
|
||||
$message=$this->tooShort!==null?$this->tooShort:Yii::t('yii','{attribute} is too short (minimum is {min} characters).');
|
||||
|
||||
Reference in New Issue
Block a user