Skip to content
Snippets Groups Projects
Commit facfe537 authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Contrôle de prévention de boucles infinies pour l'Extractor

Suppression de l'utilisation des __toString, trop "magique"
parent 776bf5b0
Branches
Tags
No related merge requests found
Pipeline #19538 passed
...@@ -7,6 +7,8 @@ use Doctrine\ORM\Query; ...@@ -7,6 +7,8 @@ use Doctrine\ORM\Query;
class AxiosExtractor class AxiosExtractor
{ {
public static $loopControl = 50;
const DATETIME_FORMAT = 'Y-m-d\TH:i:s.u\Z'; // timestamp ISO 8601 pour HTML5 const DATETIME_FORMAT = 'Y-m-d\TH:i:s.u\Z'; // timestamp ISO 8601 pour HTML5
protected array $triggers = []; protected array $triggers = [];
...@@ -53,6 +55,12 @@ class AxiosExtractor ...@@ -53,6 +55,12 @@ class AxiosExtractor
protected function extractObject($data, array $properties, string $path = ''): array protected function extractObject($data, array $properties, string $path = ''): array
{ {
// contrôle de boucle récursive, afin de ne pas saturer la mémoire...
if (substr_count($path, '/') >= self::$loopControl){
//return [];
throw new \Exception("AxiosExtractor has detected a possible infinite loop, and aborted your script with a stack depth of '".self::$loopControl."' frames");
}
$result = []; $result = [];
$props = ['id']; $props = ['id'];
...@@ -64,10 +72,6 @@ class AxiosExtractor ...@@ -64,10 +72,6 @@ class AxiosExtractor
$props[] = $prop; $props[] = $prop;
} }
} }
} else {
if (method_exists($data, '__toString')) {
$props[] = '__toString';
}
} }
} else { } else {
foreach ($properties as $prop) { foreach ($properties as $prop) {
...@@ -100,11 +104,6 @@ class AxiosExtractor ...@@ -100,11 +104,6 @@ class AxiosExtractor
} }
} }
if (array_key_exists('__toString', $result)) {
$result['libelle'] = $result['__toString'];
unset($result['__toString']);
}
return $result; return $result;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment