note 83997 added to function.unserialize

From: Date: Mon, 23 Jun 2008 12:18:22 +0000
Subject: note 83997 added to function.unserialize
Groups: php.notes 
Request: Send a blank email to php-notes+get-140734@lists.php.net to get a copy of this message
props to steve at bluearena dot com and getmequick at gmail dot com when using the regex proposed by steve at bluearena dot com when working with serialized objects that have been utf-8 encoded, i ran into a problem... "\0" became 2 characters, instead of the zero ascii character. the solution is pretty subtle: <? php # zero ascii "\0" becomes '\0' $error = preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'", $unserialized ); $works = preg_replace('!s:(\d+):"(.*?)";!se', '"s:".strlen("$2").":\"$2\";"', $unserialized ); ?> ---- Server IP: 194.153.94.10 Probable Submitter: 84.73.172.179 ---- Manual Page -- http://www.php.net/manual/en/function.unserialize.php Edit -- https://master.php.net/note/edit/83997 Del: integrated -- https://master.php.net/note/delete/83997/integrated Del: useless -- https://master.php.net/note/delete/83997/useless Del: bad code -- https://master.php.net/note/delete/83997/bad+code Del: spam -- https://master.php.net/note/delete/83997/spam Del: non-english -- https://master.php.net/note/delete/83997/non-english Del: in docs -- https://master.php.net/note/delete/83997/in+docs Del: other reasons-- https://master.php.net/note/delete/83997 Reject -- https://master.php.net/note/reject/83997 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#140734) next »