[], ]; /** * @param \Cake\Event\Event $event * @param string|array $url A string or array containing the redirect location * @param \Cake\Http\Response $response The response object. * * @return \Cake\Http\Response|null */ public function beforeRedirect(Event $event, $url, Response $response) { $actions = $this->getConfig('actions'); $currentAction = $this->getController()->getRequest()->getParam('action'); if ($actions && !in_array($currentAction, $actions, true)) { return null; } $referer = $this->referer(); if (!$referer) { return null; } return $response->withLocation($referer); } /** * Only accept relative URLs. * * @see \Cake\Http\ServerRequest::referer() * * @return string|null */ protected function referer() { $referer = $this->getController()->getRequest()->getQuery(static::QUERY_REFERER); if (!$referer) { return null; } if (strpos($referer, '/') !== 0) { return null; } return $referer; } }