From 3b314a0adf23c61440746e386751e0e45e5c03f2 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Wed, 11 Sep 2013 03:22:09 +0000 Subject: [PATCH] Improve clarity and speed of [25320]. git-svn-id: https://develop.svn.wordpress.org/trunk@25338 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/functions.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index 41428ce430..2cab41acd7 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -262,8 +262,15 @@ function is_serialized( $data, $strict = true ) { if ( ';' !== $lastc && '}' !== $lastc ) return false; } else { - // ensures ; or } exists but is not in the first X chars - if ( strpos( $data, ';' ) < 3 && strpos( $data, '}' ) < 4 ) + $semicolon = strpos( $data, ';' ); + $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; } $token = $data[0];