diff --git a/system/Honeypot/Honeypot.php b/system/Honeypot/Honeypot.php
index c2f3cf67cc7b..82da90020cac 100644
--- a/system/Honeypot/Honeypot.php
+++ b/system/Honeypot/Honeypot.php
@@ -89,16 +89,16 @@ public function attachHoneypot(ResponseInterface $response)
$prepField = $this->prepareTemplate($this->config->template);
- $body = $response->getBody();
- $body = str_ireplace('', $prepField . '', $body);
+ $bodyBefore = $response->getBody();
+ $bodyAfter = str_ireplace('', $prepField . '', $bodyBefore);
- if ($response->getCSP()->enabled()) {
+ if ($response->getCSP()->enabled() && ($bodyBefore !== $bodyAfter)) {
// Add style tag for the container tag in the head tag.
- $style = '';
- $body = str_ireplace('', $style . '', $body);
+ $style = '';
+ $bodyAfter = str_ireplace('', $style . '', $bodyAfter);
}
- $response->setBody($body);
+ $response->setBody($bodyAfter);
}
/**