Improve clarity and speed of [25320].

Built from https://develop.svn.wordpress.org/trunk@25338


git-svn-id: http://core.svn.wordpress.org/trunk@25300 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2013-09-11 03:23:08 +00:00
parent d637330d43
commit 89c57124da
1 changed files with 9 additions and 2 deletions

View File

@ -262,8 +262,15 @@ function is_serialized( $data, $strict = true ) {
if ( ';' !== $lastc && '}' !== $lastc ) if ( ';' !== $lastc && '}' !== $lastc )
return false; return false;
} else { } else {
// ensures ; or } exists but is not in the first X chars $semicolon = strpos( $data, ';' );
if ( strpos( $data, ';' ) < 3 && strpos( $data, '}' ) < 4 ) $brace = strpos( $data, '}' );
// Either ; or } must exist.
if ( false === $semicolon && false === $brace )
return false;
// But neither must be in the first X characters.
if ( false !== $semicolon && $semicolon < 3 )
return false;
if ( false !== $brace && $brace < 4 )
return false; return false;
} }
$token = $data[0]; $token = $data[0];