diff --git a/EventListener/AlertifyListener.php b/EventListener/AlertifyListener.php index ec2c9d0..51008ba 100644 --- a/EventListener/AlertifyListener.php +++ b/EventListener/AlertifyListener.php @@ -63,11 +63,14 @@ protected function injectAlertify(Response $response, Request $request) } $content = $response->getContent(); - $pos = strripos($content, ''); + $endBodyPos = strripos($content, ''); + $hasBody = false !== $endBodyPos; + $hasMetaRefresh = false !== strripos($content, 'http-equiv="refresh"'); + $isRedirectResponse = $response instanceof RedirectResponse; - if (false !== $pos) { + if ($hasBody && !$hasMetaRefresh && !$isRedirectResponse) { $alertify = $this->alertifySessionHandler->handle($this->session); - $content = substr($content, 0, $pos).$alertify.substr($content, $pos); + $content = substr($content, 0, $endBodyPos).$alertify.substr($content, $endBodyPos); $response->setContent($content); } }