mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-31 01:34:09 +02:00
Merge pull request #3486 from Icinga/fix/request-parses-json-without-respecting-content-type-3484
Fix that Request parses json without respecting content type
This commit is contained in:
commit
189b519135
@ -124,8 +124,24 @@ class Request extends Zend_Controller_Request_Http
|
|||||||
|
|
||||||
public function getPost($key = null, $default = null)
|
public function getPost($key = null, $default = null)
|
||||||
{
|
{
|
||||||
return $key === null && $this->isApiRequest()
|
if ($key === null && $this->extractMediaType($this->getHeader('Content-Type')) === 'application/json') {
|
||||||
? Json::decode(file_get_contents('php://input'), true)
|
return Json::decode(file_get_contents('php://input'), true);
|
||||||
: parent::getPost($key, $default);
|
}
|
||||||
|
|
||||||
|
return parent::getPost($key, $default);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract and return the media type from the given header value
|
||||||
|
*
|
||||||
|
* @param string $headerValue
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function extractMediaType($headerValue)
|
||||||
|
{
|
||||||
|
// Pretty basic and does not care about parameters
|
||||||
|
$parts = explode(';', $headerValue, 2);
|
||||||
|
return strtolower(trim($parts[0]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user