mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 06:15:19 +08:00
#10574 - Fix for BaseArrayHelper to work with invalid characters in proper way
This commit is contained in:
@ -467,15 +467,15 @@ class BaseArrayHelper
|
||||
public static function htmlEncode($data, $valuesOnly = true, $charset = null)
|
||||
{
|
||||
if ($charset === null) {
|
||||
$charset = Yii::$app->charset;
|
||||
$charset = Yii::$app ? Yii::$app->charset : 'UTF-8';
|
||||
}
|
||||
$d = [];
|
||||
foreach ($data as $key => $value) {
|
||||
if (!$valuesOnly && is_string($key)) {
|
||||
$key = htmlspecialchars($key, ENT_QUOTES, $charset);
|
||||
$key = htmlspecialchars($key, ENT_QUOTES | ENT_SUBSTITUTE, $charset);
|
||||
}
|
||||
if (is_string($value)) {
|
||||
$d[$key] = htmlspecialchars($value, ENT_QUOTES, $charset);
|
||||
$d[$key] = htmlspecialchars($value, ENT_QUOTES | ENT_SUBSTITUTE, $charset);
|
||||
} elseif (is_array($value)) {
|
||||
$d[$key] = static::htmlEncode($value, $valuesOnly, $charset);
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user