Skip to content

Commit

Permalink
Merge pull request #8316 from kenjis/fix-Honeypot-DEPRECATED
Browse files Browse the repository at this point in the history
fix: DEPRECATED error in Honeypot
  • Loading branch information
kenjis authored Dec 9, 2023
2 parents ba8c285 + 3f1a71b commit 3e1046b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions system/Honeypot/Honeypot.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ public function hasContent(RequestInterface $request)
*/
public function attachHoneypot(ResponseInterface $response)
{
if ($response->getBody() === null) {
return;
}

if ($response->getCSP()->enabled()) {
// Add id attribute to the container tag.
$this->config->container = str_ireplace(
Expand Down
9 changes: 9 additions & 0 deletions tests/system/Honeypot/HoneypotTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ public function testAttachHoneypot(): void
$this->assertStringNotContainsString($this->config->name, $this->response->getBody());
}

public function testAttachHoneypotBodyNull(): void
{
$this->response->setBody(null);

$this->honeypot->attachHoneypot($this->response);

$this->assertNull($this->response->getBody());
}

public function testAttachHoneypotAndContainer(): void
{
$this->response->setBody('<form></form>');
Expand Down

0 comments on commit 3e1046b

Please sign in to comment.