Fix multiple serialized values

This commit is contained in:
Philipp
2023-02-19 12:57:39 +01:00
parent 7560939d75
commit d772331b91
4 changed files with 71 additions and 6 deletions

View File

@@ -28,10 +28,24 @@ namespace Friendica\Core\Config\Util;
*/
class SerializeUtil
{
/**
* Checks if the value needs to get unserialized and returns the unserialized value
*
* @param mixed $value A possible serialized value
*
* @return mixed The unserialized value
*/
public static function maybeUnserialize($value)
{
if (static::isSerialized($value)) {
return @unserialize(trim($value));
// This checks for possible multiple serialized values
while (SerializeUtil::isSerialized($value)) {
$oldValue = $value;
$value = @unserialize($value);
// If there's no change after the unserialize call, break the loop (avoid endless loops)
if ($oldValue === $value) {
break;
}
}
return $value;