Make WordPress Core

Changeset 17779


Ignore:
Timestamp:
04/30/2011 04:41:56 AM (13 years ago)
Author:
markjaquith
Message:

Speed optimizations for is_serialized_string(). fixes #17129

File:
1 edited

Legend:

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

    r17751 r17779  
    279279        return false;
    280280    $data = trim( $data );
    281     if ( preg_match( '/^s:[0-9]+:.*;$/s', $data ) ) // this should fetch all serialized strings
     281    $length = strlen( $data );
     282    if ( $length < 4 )
     283        return false;
     284    elseif ( ':' !== $data[1] )
     285        return false;
     286    elseif ( ';' !== $data[$length-1] )
     287        return false;
     288    elseif ( $data[0] !== 's' )
     289        return false;
     290    elseif ( '"' !== $data[$length-2] )
     291        return false;
     292    else
    282293        return true;
    283     return false;
    284294}
    285295
Note: See TracChangeset for help on using the changeset viewer.