From 0dcb74ef193d98a4d80322a21535bb54eec0ceaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Jaussoin?= Date: Mon, 30 Dec 2024 17:22:03 +0100 Subject: [PATCH] Fix FLEXIAPI-254 Allow no data on POST requests to not trigger the ValidateJSON middleware --- CHANGELOG.md | 1 + .../Http/Controllers/Api/Account/PushNotificationController.php | 1 + flexiapi/app/Http/Middleware/ValidateJSON.php | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b73fc40..d0b168d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ v1.7 - Fix FLEXIAPI-244 Remove faulty middleware - Fix FLEXIAPI-250 Allow Spaces to be declared without a subdomain - Fix FLEXIAPI-252 Update the hCaptcha Laravel library, use file instead of cookies to store the session to prevent empty errors bags +- Fix FLEXIAPI-254 Allow no data on POST requests to not trigger the ValidateJSON middleware v1.6 ---- diff --git a/flexiapi/app/Http/Controllers/Api/Account/PushNotificationController.php b/flexiapi/app/Http/Controllers/Api/Account/PushNotificationController.php index 9b7badf..0c0d3a9 100644 --- a/flexiapi/app/Http/Controllers/Api/Account/PushNotificationController.php +++ b/flexiapi/app/Http/Controllers/Api/Account/PushNotificationController.php @@ -10,6 +10,7 @@ use App\Rules\PnProvider; use App\Rules\CallId; use Illuminate\Http\Request; use Illuminate\Validation\Rule; +use Illuminate\Support\Facades\Log; class PushNotificationController extends Controller { diff --git a/flexiapi/app/Http/Middleware/ValidateJSON.php b/flexiapi/app/Http/Middleware/ValidateJSON.php index 0869c69..1155776 100644 --- a/flexiapi/app/Http/Middleware/ValidateJSON.php +++ b/flexiapi/app/Http/Middleware/ValidateJSON.php @@ -11,7 +11,7 @@ class ValidateJSON public function handle(Request $request, Closure $next) { - if ($request->expectsJson()) { + if ($request->expectsJson() && !empty($request->getContent())) { json_decode($request->getContent()); if (json_last_error() !== JSON_ERROR_NONE) { abort(400, self::$message . ': ' . json_last_error_msg());