Skip to content

Commit bd790c0

Browse files
fix(cache): Set DONOTCACHEPAGE to true for ban and captcha walls to prevent them from being cached (#169)
* test(e2e): Fix playwright to 1.52 as there is ERR_ABORTED on page.goto with 1.53.0 * fix(cache): Set DONOTCACHEPAGE to true for ban and captcha walls
1 parent 6148b19 commit bd790c0

File tree

6 files changed

+30
-5
lines changed

6 files changed

+30
-5
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
---
88

9+
## [2.11.1](https://github.com/crowdsecurity/cs-wordpress-bouncer/releases/tag/v2.11.1) - 2025-06-13
10+
[_Compare with previous release_](https://github.com/crowdsecurity/cs-wordpress-bouncer/compare/v2.11.0...v2.11.1)
11+
12+
13+
### Fixed
14+
15+
- Set the `DONOTCACHEPAGE` constant to true for ban and captcha walls to prevent them from being cached by WordPress "cache" plugins.
16+
17+
---
18+
919
## [2.11.0](https://github.com/crowdsecurity/cs-wordpress-bouncer/releases/tag/v2.11.0) - 2025-06-02
1020
[_Compare with previous release_](https://github.com/crowdsecurity/cs-wordpress-bouncer/compare/v2.10.0...v2.11.0)
1121

crowdsec.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Plugin URI: https://github.com/crowdsecurity/cs-wordpress-bouncer
55
* Description: Safer Together. Protect your WordPress application with CrowdSec.
66
* Tags: security, captcha, ip-blocker, crowdsec, hacker-protection, appsec
7-
* Version: 2.11.0
7+
* Version: 2.11.1
88
* Author: CrowdSec
99
* Author URI: https://www.crowdsec.net/
1010
* Github: https://github.com/crowdsecurity/cs-wordpress-bouncer
@@ -13,7 +13,7 @@
1313
* Requires PHP: 7.2
1414
* Requires at least: 4.9
1515
* Tested up to: 6.8
16-
* Stable tag: 2.11.0
16+
* Stable tag: 2.11.1
1717
* Text Domain: crowdsec-wp
1818
* First release: 2021.
1919
*/

inc/Bouncer.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,21 @@ protected function getCaptchaHtml(
433433
return $this->renderTemplate('captcha-wall.php', $configs);
434434
}
435435

436+
protected function sendResponse(string $body, int $statusCode): void
437+
{
438+
/**
439+
* Ban and Captcha walls should not be cached.
440+
* If the status code is 401 or 403, we define DONOTCACHEPAGE to true because some WordPress "cache" plugins
441+
* use this constant to prevent caching of the page.
442+
*/
443+
if(in_array($statusCode, [401, 403]) && !defined('DONOTCACHEPAGE')) {
444+
define('DONOTCACHEPAGE', true);
445+
}
446+
447+
parent::sendResponse($body, $statusCode);
448+
}
449+
450+
436451
protected function specialcharsDecodeEntQuotes(string $value): string
437452
{
438453
return htmlspecialchars_decode($value, \ENT_QUOTES);

inc/Constants.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ class Constants extends LibConstants
2121
public const BOUNCER_NAME = 'wordpress-bouncer';
2222
public const DEFAULT_BASE_FILE_PATH = __DIR__ . '/../../../../wp-content/uploads/crowdsec/';
2323
public const STANDALONE_CONFIG_PATH = __DIR__ . '/standalone-settings.php';
24-
public const VERSION = 'v2.11.0';
24+
public const VERSION = 'v2.11.1';
2525
}

readme.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Donate link: https://crowdsec.net/
44
Tags: security, captcha, ip-blocker, crowdsec, hacker-protection
55
Requires at least: 4.9
66
Tested up to: 6.8
7-
Stable tag: 2.11.0
7+
Stable tag: 2.11.1
88
Requires PHP: 7.2
99
License: MIT
1010
License URI: https://opensource.org/licenses/MIT

tests/e2e-ddev/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"jest-playwright-preset": "^3.0.1",
2424
"jest-runner": "^29.4.2",
2525
"lodash": "^4.17.21",
26-
"playwright-chromium": "^1.26.1",
26+
"playwright-chromium": "1.52.0",
2727
"ws": "^7.4.6"
2828
}
2929
}

0 commit comments

Comments
 (0)