Make WordPress Core


Ignore:
Timestamp:
12/22/2009 01:10:06 PM (17 years ago)
Author:
westi
Message:

Much improved is_serialized() which catches serialized doubles. Fixes #9930 props vladimir_kolesnikov and dd32.

File:
1 edited

Legend:

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

    r12412 r12485  
    246246 */
    247247function is_serialized( $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;
     248        return is_string($data) && preg_match('/^(N;)|([aOs]:[0-9]+:.*[;}])|([bid]:[0-9.E+-]+;)$/s', $data);
    271249}
    272250
Note: See TracChangeset for help on using the changeset viewer.