Skip to content

Commit 5cd0c64

Browse files
Merge pull request #93 from julienloizelet/fix/91-session-start-error-header-already-sent
Fix/91 session start error header already sent
2 parents 75f0bcb + c5a7053 commit 5cd0c64

File tree

5 files changed

+14
-4
lines changed

5 files changed

+14
-4
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
8+
## [1.4.3] - 2022-05-13
9+
10+
### Fixed
11+
- Do not bounce if headers are already sent
12+
713
## [1.4.2] - 2022-05-13
814

915
### Added

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: crowdsec-bouncer, wordpress, security, firewall, captcha, ip-scanner, ip-blocker, ip-blocking, ip-address, ip-database, ip-range-check, crowdsec, ban-hosts, ban-management, anti-hacking, hacker-protection, captcha-image, captcha-generator, captcha-generation, captcha-service
7-
* Version: 1.4.2
7+
* Version: 1.4.3
88
* Author: CrowdSec
99
* Author URI: https://www.crowdsec.net/
1010
* Github: https://github.com/crowdsecurity/cs-wordpress-blocker
@@ -13,7 +13,7 @@
1313
* Requires PHP: 7.2
1414
* Requires at least: 4.9
1515
* Tested up to: 5.9
16-
* Stable tag: 1.4.2
16+
* Stable tag: 1.4.3
1717
* Text Domain: crowdsec-wp
1818
* First release: 2021.
1919
*/

inc/Bounce.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,10 @@ public function sendResponse(?string $body, int $statusCode = 200): void
317317

318318
public function safelyBounce(array $configs): bool
319319
{
320+
if (headers_sent()) {
321+
// We cannot start session when headers already sent
322+
return false;
323+
}
320324
// If there is any technical problem while bouncing, don't block the user. Bypass boucing and log the error.
321325
set_error_handler(function ($errno, $errstr) {
322326
throw new BouncerException("$errstr (Error level: $errno)");

inc/constants.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ function crowdsecDefineConstants(string $crowdsecRandomLogFolder)
88
define('CROWDSEC_DEBUG_LOG_PATH', __DIR__."/../logs/$crowdsecRandomLogFolder/debug.log");
99
define('CROWDSEC_CACHE_PATH', __DIR__.'/../.cache');
1010
define('CROWDSEC_CONFIG_PATH', __DIR__.'/standalone-settings.php');
11-
define('CROWDSEC_BOUNCER_USER_AGENT', 'WordPress CrowdSec Bouncer/v1.4.2');
11+
define('CROWDSEC_BOUNCER_USER_AGENT', 'WordPress CrowdSec Bouncer/v1.4.3');
1212
}
1313
}

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: crowdsec-bouncer, wordpress, security, firewall, captcha, ip-scanner, ip-blocker, ip-blocking, ip-address, ip-database, ip-range-check, crowdsec, ban-hosts, ban-management, anti-hacking, hacker-protection, captcha-image, captcha-generator, captcha-generation, captcha-service
55
Requires at least: 4.9
66
Tested up to: 5.9
7-
Stable tag: 1.4.2
7+
Stable tag: 1.4.3
88
Requires PHP: 7.2
99
License: MIT
1010
License URI: https://opensource.org/licenses/MIT

0 commit comments

Comments
 (0)