Fixed: Improved user profile field encoding

This commit is contained in:
Lucas Bartholemy 2015-11-17 16:58:51 +01:00
parent 6bca36b92d
commit 381aca4834
4 changed files with 13 additions and 7 deletions

View File

@ -260,7 +260,13 @@ class BaseType extends \yii\base\Model
public function getUserValue($user, $raw = true)
{
$internalName = $this->profileField->internal_name;
return $user->profile->$internalName;
if ($raw) {
return $user->profile->$internalName;
} else {
return \yii\helpers\Html::encode($user->profile->$internalName);
}
}
public function getLabels()

View File

@ -113,8 +113,8 @@ class DateTime extends BaseType
if ($date == "" || $date == "0000-00-00 00:00:00")
return "";
return $date;
return \yii\helpers\Html::encode($date);
}
/**

View File

@ -140,7 +140,7 @@ class Select extends BaseType
if (!$raw) {
$options = $this->getSelectItems();
if (isset($options[$value])) {
return Yii::t($this->profileField->getTranslationCategory(), $options[$value]);
return \yii\helpers\Html::encode(Yii::t($this->profileField->getTranslationCategory(), $options[$value]));
}
}

View File

@ -193,12 +193,12 @@ class Text extends BaseType
$value = $user->profile->$internalName;
if (!$raw && $this->validator == self::VALIDATOR_EMAIL) {
return \yii\helpers\Html::a($value, $value);
return \yii\helpers\Html::a(\yii\helpers\Html::encode($value), $value);
} elseif (!$raw && $this->validator == self::VALIDATOR_URL) {
return \yii\helpers\Html::a($value, $value, array('target' => '_blank'));
return \yii\helpers\Html::a(\yii\helpers\Html::encode($value), $value, array('target' => '_blank'));
}
return $value;
return \yii\helpers\Html::encode($value);
}
}