From 41dd7d25b729b64f84fe59fd30ec0d658a99de1b Mon Sep 17 00:00:00 2001 From: westi Date: Tue, 22 Dec 2009 13:42:58 +0000 Subject: [PATCH] Revert [12485] as it breaks the functionality of is_serialized() and make more strings appear serialized. See #9930. git-svn-id: http://svn.automattic.com/wordpress/trunk@12486 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/functions.php | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index bc0b8ba90..22b962c0f 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -245,7 +245,29 @@ function maybe_unserialize( $original ) { * @return bool False if not serialized and true if it was. */ function is_serialized( $data ) { - return is_string($data) && preg_match('/^(N;)|([aOs]:[0-9]+:.*[;}])|([bid]:[0-9.E+-]+;)$/s', $data); + // if it isn't a string, it isn't serialized + if ( !is_string( $data ) ) + return false; + $data = trim( $data ); + if ( 'N;' == $data ) + return true; + if ( !preg_match( '/^([adObis]):/', $data, $badions ) ) + return false; + switch ( $badions[1] ) { + case 'a' : + case 'O' : + case 's' : + if ( preg_match( "/^{$badions[1]}:[0-9]+:.*[;}]\$/s", $data ) ) + return true; + break; + case 'b' : + case 'i' : + case 'd' : + if ( preg_match( "/^{$badions[1]}:[0-9.E-]+;\$/", $data ) ) + return true; + break; + } + return false; } /**