From 65e56408104b702fe21eb1639dbaa6ffaa47900f Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Thu, 26 Mar 2020 12:30:56 +0300 Subject: [PATCH] Fix #17932: Fix regression in detection of AJAX requests (#17937) --- framework/CHANGELOG.md | 2 +- framework/web/Request.php | 8 +------- tests/framework/web/RequestTest.php | 18 ------------------ 3 files changed, 2 insertions(+), 26 deletions(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index d5b0523fcb..46cddc9b6e 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -4,7 +4,7 @@ Yii Framework 2 Change Log 2.0.34 under development ------------------------ -- no changes in this release. +- Bug #17932: Fix regression in detection of AJAX requests (samdark) 2.0.33 March 24, 2020 diff --git a/framework/web/Request.php b/framework/web/Request.php index 95ef8e583a..a99c2b3d37 100644 --- a/framework/web/Request.php +++ b/framework/web/Request.php @@ -487,13 +487,7 @@ class Request extends \yii\base\Request */ public function getIsAjax() { - $origin = $this->headers->get('Origin'); - - return - ($this->headers->get('X-Requested-With') === 'XMLHttpRequest') || - ($this->headers->get('Sec-Fetch-Mode') === 'cors') || - ($this->headers->get('Sec-Fetch-Site') === 'cross-site') || - ($origin !== null && $origin !== $this->getHostInfo()); + return $this->headers->get('X-Requested-With') === 'XMLHttpRequest'; } /** diff --git a/tests/framework/web/RequestTest.php b/tests/framework/web/RequestTest.php index af7770b363..934148b198 100644 --- a/tests/framework/web/RequestTest.php +++ b/tests/framework/web/RequestTest.php @@ -908,24 +908,6 @@ class RequestTest extends TestCase ], true, ], - [ - [ - 'HTTP_Sec-Fetch-Mode' => 'cors', - ], - true, - ], - [ - [ - 'HTTP_Sec-Fetch-Site' => 'cross-site', - ], - true, - ], - [ - [ - 'HTTP_Origin' => 'https://example.com/', - ], - true, - ], ]; }