Ensure error handling for invalid json_decode output by adding array validation checks across routes, traits, and response methods. Replace echo statements with standardized response error handling in module_config_t.

This commit is contained in:
Jeppe Bundgaard
2026-01-13 11:56:17 +01:00
parent f0f87eb351
commit 60244dd106
8 changed files with 44 additions and 10 deletions
+3 -5
View File
@@ -529,11 +529,9 @@ trait route_t
public function fromRequest(string $name): ?string
{
// If the $_POST variable is set, return the value from the POST variable, otherwise return the value from the query string
if (isset($_POST)) {
$data = json_decode(file_get_contents('php://input'), true);
if (isset($data[$name])) {
return $data[$name];
}
$data = json_decode(file_get_contents('php://input'), true);
if (is_array($data) && isset($data[$name])) {
return $data[$name];
}
return (isset($_POST[$name])) ? $_POST[$name] : $this->fromQuery($name);
}