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; } /**