Sanitize $grav['task']`

This commit is contained in:
Matias Griese
2018-11-30 13:14:10 +02:00
parent 180f3c2eca
commit db2738978e
2 changed files with 8 additions and 3 deletions

View File

@@ -26,6 +26,7 @@ class TasksProcessor extends ProcessorBase
$task = $this->container['task'];
if ($task) {
$attributes = $request->getAttribute('controller');
$controllerClass = $attributes['class'] ?? null;
if ($controllerClass) {
/** @var RequestHandlerInterface $controller */

View File

@@ -16,9 +16,13 @@ class TaskServiceProvider implements ServiceProviderInterface
{
public function register(Container $container)
{
$container['task'] = function ($c) {
/** @var Grav $c */
return !empty($_POST['task']) ? $_POST['task'] : $c['uri']->param('task');
$container['task'] = function (Grav $c) {
$task = $_POST['task'] ?? $c['uri']->param('task');
if (null !== $task) {
$task = filter_var($task, FILTER_SANITIZE_STRING);
}
return $task ?: null;
};
}
}