From 6849a47545fbb5d3a8ef8497a3c9bc014d1fa177 Mon Sep 17 00:00:00 2001 From: Cameron Date: Wed, 22 May 2019 13:57:26 -0700 Subject: [PATCH] Issue #2990 - unserialize BC fix. --- e107_handlers/core_functions.php | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/e107_handlers/core_functions.php b/e107_handlers/core_functions.php index 56744f291..84db8b4ea 100644 --- a/e107_handlers/core_functions.php +++ b/e107_handlers/core_functions.php @@ -433,7 +433,8 @@ class e_array { $ArrayData = $sourceArrayData; - if ($ArrayData == ""){ + if ($ArrayData == "") + { return false; } @@ -448,8 +449,7 @@ class e_array { $dat = unserialize($ArrayData); $ArrayData = $this->WriteArray($dat,FALSE); } - - if(substr($ArrayData,0,1) === '{' || substr($ArrayData,0,1) === '[') // json + elseif(strpos($ArrayData,'{') === 0 || strpos($ArrayData,'[') === 0) // json { $dat = json_decode($ArrayData, true); @@ -484,6 +484,10 @@ class e_array { { $ArrayData = stripslashes($ArrayData); } + elseif(strpos($ArrayData,'array') === 0 && strpos($ArrayData,"\' => \'") !== false) + { + $ArrayData = stripslashes($ArrayData); + } $ArrayData = str_replace('=>','=>',$ArrayData); //FIX for PDO encoding of strings. . @@ -516,10 +520,11 @@ class e_array { echo "
";
 					debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3);
 					echo "
"; - + file_put_contents(e_LOG.'unserializeError_'.time().'.log', $sourceArrayData); } - e107::getAdminLog()->addError($sourceArrayData)->toFile('unserializeError_'.time().'.log','e107::unserialize',false); + // e107::getAdminLog()->addError($sourceArrayData)->toFile('unserializeError_'.time().'.log','e107::unserialize',false); + return array(); @@ -533,6 +538,12 @@ class e_array { if (!isset($data) || !is_array($data)) { trigger_error("Bad stored array data -

".htmlentities($ArrayData), E_USER_ERROR); + + if(e_DEBUG === true) + { + file_put_contents(e_LOG.'unserializeError_'.time().'.log', $sourceArrayData); + } + return false; }