mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-02 13:02:24 +08:00
Added CSRF support.
This commit is contained in:
@ -293,12 +293,16 @@ class Html
|
||||
|
||||
$hiddenInputs = array();
|
||||
|
||||
if (strcasecmp($method, 'get') && strcasecmp($method, 'post')) {
|
||||
// simulate PUT, DELETE, etc. via POST
|
||||
if (($request = Yii::$app->getRequest()) instanceof Request) {
|
||||
$request = Yii::$app->getRequest();
|
||||
if ($request instanceof Request) {
|
||||
if (strcasecmp($method, 'get') && strcasecmp($method, 'post')) {
|
||||
// simulate PUT, DELETE, etc. via POST
|
||||
$hiddenInputs[] = static::hiddenInput($request->restVar, $method);
|
||||
$method = 'post';
|
||||
}
|
||||
if ($request->enableCsrfValidation) {
|
||||
$hiddenInputs[] = static::hiddenInput($request->csrfTokenName, $request->getCsrfToken());
|
||||
}
|
||||
}
|
||||
|
||||
if (!strcasecmp($method, 'get') && ($pos = strpos($action, '?')) !== false) {
|
||||
|
||||
Reference in New Issue
Block a user