mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-16 15:21:13 +08:00
Fixes #5587: json_encode
is now used with JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE
where it makes sense, also it is now default for Json::encode()
This commit is contained in:
@ -518,7 +518,7 @@ class StatusValidator extends Validator
|
||||
public function clientValidateAttribute($model, $attribute, $view)
|
||||
{
|
||||
$statuses = json_encode(Status::find()->select('id')->asArray()->column());
|
||||
$message = json_encode($this->message);
|
||||
$message = json_encode($this->message, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
|
||||
return <<<JS
|
||||
if (!$.inArray(value, $statuses)) {
|
||||
messages.push($message);
|
||||
|
@ -231,7 +231,7 @@ EOD;
|
||||
*/
|
||||
public function getKeywordsArrayJson()
|
||||
{
|
||||
return json_encode(explode(',', $this->keywords));
|
||||
return json_encode(explode(',', $this->keywords), JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -8,6 +8,8 @@ Yii Framework 2 Change Log
|
||||
- Bug #5584: `yii\rbac\DbRbacManager` should not delete items when deleting a rule on a database not supporting cascade update (mdmunir)
|
||||
- Bug #5601: Simple conditions in Query::where() and ActiveQuery::where() did not allow `yii\db\Expression` to be used as the value (cebe, stevekr)
|
||||
- Bug: Gii console command help information does not contain global options (qiangxue)
|
||||
- Enh #5587: `json_encode` is now used with `JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE` where it makes sense, also
|
||||
it is now default for `Json::encode()` (samdark)
|
||||
- Enh #5600: Allow configuring debug panels in `yii\debug\Module::panels` as panel class name strings (qiangxue)
|
||||
- Enh #5613: Added `--overwrite` option to Gii console command to support overwriting all files (motin, qiangxue)
|
||||
- Enh #5646: Call `yii\base\ErrorHandler::unregister()` instead of `restore_*_handlers` directly (aivus)
|
||||
|
@ -127,7 +127,7 @@ class CaptchaAction extends Action
|
||||
// we add a random 'v' parameter so that FireFox can refresh the image
|
||||
// when src attribute of image tag is changed
|
||||
'url' => Url::to([$this->id, 'v' => uniqid()]),
|
||||
]);
|
||||
], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
|
||||
} else {
|
||||
$this->setHttpHeaders();
|
||||
Yii::$app->response->format = Response::FORMAT_RAW;
|
||||
|
@ -103,6 +103,6 @@ class CaptchaValidator extends Validator
|
||||
|
||||
ValidationAsset::register($view);
|
||||
|
||||
return 'yii.validation.captcha(value, messages, ' . json_encode($options) . ');';
|
||||
return 'yii.validation.captcha(value, messages, ' . json_encode($options, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . ');';
|
||||
}
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ class CheckboxColumn extends Column
|
||||
'name' => $this->name,
|
||||
'multiple' => $this->multiple,
|
||||
'checkAll' => $name,
|
||||
]);
|
||||
], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
|
||||
$this->grid->getView()->registerJs("jQuery('#$id').yiiGridView('setSelectionColumn', $options);");
|
||||
|
||||
if ($this->header !== null || !$this->multiple) {
|
||||
@ -104,7 +104,7 @@ class CheckboxColumn extends Column
|
||||
} else {
|
||||
$options = $this->checkboxOptions;
|
||||
if (!isset($options['value'])) {
|
||||
$options['value'] = is_array($key) ? json_encode($key) : $key;
|
||||
$options['value'] = is_array($key) ? json_encode($key, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) : $key;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,10 +28,10 @@ class BaseJson
|
||||
* represented in terms of a [[JsExpression]] object.
|
||||
* @param mixed $value the data to be encoded
|
||||
* @param integer $options the encoding options. For more details please refer to
|
||||
* <http://www.php.net/manual/en/function.json-encode.php>.
|
||||
* <http://www.php.net/manual/en/function.json-encode.php>. Default is `JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE`.
|
||||
* @return string the encoding result
|
||||
*/
|
||||
public static function encode($value, $options = 0)
|
||||
public static function encode($value, $options = 320)
|
||||
{
|
||||
$expressions = [];
|
||||
$value = static::processData($value, $expressions, uniqid());
|
||||
|
@ -87,6 +87,6 @@ class BooleanValidator extends Validator
|
||||
|
||||
ValidationAsset::register($view);
|
||||
|
||||
return 'yii.validation.boolean(value, messages, ' . json_encode($options) . ');';
|
||||
return 'yii.validation.boolean(value, messages, ' . json_encode($options, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . ');';
|
||||
}
|
||||
}
|
||||
|
@ -229,6 +229,6 @@ class CompareValidator extends Validator
|
||||
|
||||
ValidationAsset::register($view);
|
||||
|
||||
return 'yii.validation.compare(value, messages, ' . json_encode($options) . ');';
|
||||
return 'yii.validation.compare(value, messages, ' . json_encode($options, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . ');';
|
||||
}
|
||||
}
|
||||
|
@ -338,7 +338,7 @@ class FileValidator extends Validator
|
||||
{
|
||||
ValidationAsset::register($view);
|
||||
$options = $this->getClientOptions($object, $attribute);
|
||||
return 'yii.validation.file(attribute, messages, ' . json_encode($options) . ');';
|
||||
return 'yii.validation.file(attribute, messages, ' . json_encode($options, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . ');';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -166,7 +166,7 @@ class ImageValidator extends FileValidator
|
||||
{
|
||||
ValidationAsset::register($view);
|
||||
$options = $this->getClientOptions($object, $attribute);
|
||||
return 'yii.validation.image(attribute, messages, ' . json_encode($options) . ', deferred);';
|
||||
return 'yii.validation.image(attribute, messages, ' . json_encode($options, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . ', deferred);';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -101,6 +101,6 @@ class RangeValidator extends Validator
|
||||
|
||||
ValidationAsset::register($view);
|
||||
|
||||
return 'yii.validation.range(value, messages, ' . json_encode($options) . ');';
|
||||
return 'yii.validation.range(value, messages, ' . json_encode($options, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . ');';
|
||||
}
|
||||
}
|
||||
|
@ -107,6 +107,6 @@ class RequiredValidator extends Validator
|
||||
|
||||
ValidationAsset::register($view);
|
||||
|
||||
return 'yii.validation.required(value, messages, ' . json_encode($options) . ');';
|
||||
return 'yii.validation.required(value, messages, ' . json_encode($options, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . ');';
|
||||
}
|
||||
}
|
||||
|
@ -183,6 +183,6 @@ class StringValidator extends Validator
|
||||
|
||||
ValidationAsset::register($view);
|
||||
|
||||
return 'yii.validation.string(value, messages, ' . json_encode($options) . ');';
|
||||
return 'yii.validation.string(value, messages, ' . json_encode($options, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . ');';
|
||||
}
|
||||
}
|
||||
|
@ -538,7 +538,7 @@ class User extends Component
|
||||
$identity->getId(),
|
||||
$identity->getAuthKey(),
|
||||
$duration,
|
||||
]);
|
||||
], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
|
||||
$cookie->expire = time() + $duration;
|
||||
Yii::$app->getResponse()->getCookies()->add($cookie);
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ class ListView extends BaseListView
|
||||
$options = $this->itemOptions;
|
||||
$tag = ArrayHelper::remove($options, 'tag', 'div');
|
||||
if ($tag !== false) {
|
||||
$options['data-key'] = is_array($key) ? json_encode($key) : (string) $key;
|
||||
$options['data-key'] = is_array($key) ? json_encode($key, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) : (string) $key;
|
||||
|
||||
return Html::tag($tag, $content, $options);
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user