switching to full JSON API without POST array use, ensure all JSON operations are done with error detection

This commit is contained in:
El RIDO 2019-05-13 22:31:52 +02:00
parent be1e7babc0
commit cc1c55129f
No known key found for this signature in database
GPG key ID: 0F5C940A6BD81F92
14 changed files with 187 additions and 103 deletions

View file

@ -107,10 +107,10 @@ class Request
switch (array_key_exists('REQUEST_METHOD', $_SERVER) ? $_SERVER['REQUEST_METHOD'] : 'GET') {
case 'DELETE':
case 'PUT':
parse_str(file_get_contents(self::$_inputStream), $this->_params);
break;
case 'POST':
$this->_params = $_POST;
$this->_params = Json::decode(
file_get_contents(self::$_inputStream)
);
break;
default:
$this->_params = $_GET;
@ -161,15 +161,15 @@ class Request
public function getData()
{
$data = array(
'adata' => json_decode($this->getParam('adata', '[]'), true),
'adata' => $this->getParam('adata', array()),
);
$required_keys = array('v', 'ct');
$meta = $this->getParam('meta');
$meta = $this->getParam('meta', array());
if (empty($meta)) {
$required_keys[] = 'pasteid';
$required_keys[] = 'parentid';
} else {
$data['meta'] = json_decode($meta, true);
$data['meta'] = $meta;
}
foreach ($required_keys as $key) {
$data[$key] = $this->getParam($key);