From d80f8f6c823c531d2c54110c7d66b802a54a86da Mon Sep 17 00:00:00 2001 From: Stanimir Bozhilov Date: Thu, 22 Sep 2022 11:25:39 +0200 Subject: Type hint JSON content type regex and use preg_match less Signed-off-by: Stanimir Bozhilov --- lib/private/AppFramework/Http/Request.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/private/AppFramework/Http') diff --git a/lib/private/AppFramework/Http/Request.php b/lib/private/AppFramework/Http/Request.php index b0392f11e09..ee569273a3f 100644 --- a/lib/private/AppFramework/Http/Request.php +++ b/lib/private/AppFramework/Http/Request.php @@ -107,7 +107,8 @@ class Request implements \ArrayAccess, \Countable, IRequest { /** @var bool */ protected $contentDecoded = false; - protected $jsonContentTypeRegex = '/application\/(\w+\+)?json/'; + /** @var string */ + protected string $jsonContentTypeRegex = '/application\/(\w+\+)?json/'; /** * @param array $vars An associative array with the following optional values: @@ -406,13 +407,12 @@ class Request implements \ArrayAccess, \Countable, IRequest { && $this->getHeader('Content-Length') !== '0' && $this->getHeader('Content-Length') !== '' && strpos($this->getHeader('Content-Type'), 'application/x-www-form-urlencoded') === false - && preg_match($this->jsonContentTypeRegex, $this->getHeader('Content-Type')) === 0 + && strpos($this->getHeader('Content-Type'), 'application/json') === false ) { if ($this->content === false) { throw new \LogicException( '"put" can only be accessed once if not ' - . 'application/x-www-form-urlencoded, application/json ' - . 'or other content type, related to JSON (like application/scim+json).' + . 'application/x-www-form-urlencoded or application/json.' ); } $this->content = false; -- cgit v1.2.3