From: Vincent Vanwaelscappel Date: Tue, 12 Jul 2022 15:49:09 +0000 (+0200) Subject: wip #4209 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=1907abaa7b92788aeb43a9961bc032d8e3fc0c1d;p=cubist_util.git wip #4209 @0.5 --- diff --git a/src/ObjectUtil.php b/src/ObjectUtil.php index 941d2ec..02056f9 100644 --- a/src/ObjectUtil.php +++ b/src/ObjectUtil.php @@ -33,5 +33,13 @@ class ObjectUtil { return (object)$o; } + public static function safeUnserialize($str) + { + $class = 'stdClass'; + $str = preg_replace('/^O:\d+:"[^"]++"/', 'O:' . strlen($class) . ':"' . $class . '"', $str); + $str = str_replace("s:8:\"\0*\0datas\"", 's:5:"datas"', $str); + return unserialize($str); + } + }