Make WordPress Core


Ignore:
Timestamp:
12/22/2009 01:42:58 PM (15 years ago)
Author:
westi
Message:

Revert [12485] as it breaks the functionality of is_serialized() and make more strings appear serialized. See #9930.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/functions.php

    r12485 r12486  
    246246 */
    247247function is_serialized( $data ) {
    248     return is_string($data) && preg_match('/^(N;)|([aOs]:[0-9]+:.*[;}])|([bid]:[0-9.E+-]+;)$/s', $data);
     248    // if it isn't a string, it isn't serialized
     249    if ( !is_string( $data ) )
     250        return false;
     251    $data = trim( $data );
     252    if ( 'N;' == $data )
     253        return true;
     254    if ( !preg_match( '/^([adObis]):/', $data, $badions ) )
     255        return false;
     256    switch ( $badions[1] ) {
     257        case 'a' :
     258        case 'O' :
     259        case 's' :
     260            if ( preg_match( "/^{$badions[1]}:[0-9]+:.*[;}]\$/s", $data ) )
     261                return true;
     262            break;
     263        case 'b' :
     264        case 'i' :
     265        case 'd' :
     266            if ( preg_match( "/^{$badions[1]}:[0-9.E-]+;\$/", $data ) )
     267                return true;
     268            break;
     269    }
     270    return false;
    249271}
    250272
Note: See TracChangeset for help on using the changeset viewer.