Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Better header catch
James Cole60d8bb2aab30
diff --git a/app/Http/Middleware/AcceptHeaders.php b/app/Http/Middleware/AcceptHeaders.phpindex 0840806438..75c6eeb45e 100644--- a/app/Http/Middleware/AcceptHeaders.php+++ b/app/Http/Middleware/AcceptHeaders.php@@ -50,8 +50,10 @@ class AcceptHeadersif ('GET' === $method && !$request->accepts(['application/json', 'application/vdn.api+json'])) {throw new BadHttpHeaderException('Your request must accept either application/json or application/vdn.api+json.');}- if (('POST' === $method || 'PUT' === $method) && 'application/json' !== (string)$request->header('Content-Type')) {- $error = new BadHttpHeaderException('Content-Type must be application/json');+ $allowed = ['application/x-www-form-urlencoded','application/json'];+ $submitted = (string)$request->header('Content-Type');+ if (('POST' === $method || 'PUT' === $method) && !in_array($submitted, $allowed, true)) {+ $error = new BadHttpHeaderException(sprintf('Content-Type cannot be "%s"', $submitted));$error->statusCode = 415;throw $error;}