| 1 | Index: wp-includes/functions.php |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- wp-includes/functions.php (revision 16104) |
|---|
| 4 | +++ wp-includes/functions.php (working copy) |
|---|
| 5 | @@ -229,34 +229,31 @@ |
|---|
| 6 | */ |
|---|
| 7 | function is_serialized( $data ) { |
|---|
| 8 | // if it isn't a string, it isn't serialized |
|---|
| 9 | - if ( !is_string( $data ) ) |
|---|
| 10 | + if ( ! is_string( $data ) ) |
|---|
| 11 | return false; |
|---|
| 12 | $data = trim( $data ); |
|---|
| 13 | if ( 'N;' == $data ) |
|---|
| 14 | return true; |
|---|
| 15 | - if ( function_exists('strpbrk') ) { |
|---|
| 16 | - if ( strlen($data) > 1 && strpbrk($data,'adObis') == $data && $data[1] == ':' ) { |
|---|
| 17 | - $badions = array(); |
|---|
| 18 | - $badions[1] = $data[0]; |
|---|
| 19 | - } else { |
|---|
| 20 | - return false; |
|---|
| 21 | - } |
|---|
| 22 | - } elseif ( !preg_match( '/^([adObis]):/', $data, $badions ) ) { |
|---|
| 23 | + $length = strlen( $data ); |
|---|
| 24 | + if ( $length < 4 ) |
|---|
| 25 | return false; |
|---|
| 26 | - } |
|---|
| 27 | - switch ( $badions[1] ) { |
|---|
| 28 | + if ( ':' !== $data[1] ) |
|---|
| 29 | + return false; |
|---|
| 30 | + $lastc = $data[$length-1]; |
|---|
| 31 | + if ( ';' !== $lastc && '}' !== $lastc ) |
|---|
| 32 | + return false; |
|---|
| 33 | + $token = $data[0]; |
|---|
| 34 | + switch ( $token ) { |
|---|
| 35 | + case 's' : |
|---|
| 36 | + if ( '"' !== $data[$length-2] ) |
|---|
| 37 | + return false; |
|---|
| 38 | case 'a' : |
|---|
| 39 | case 'O' : |
|---|
| 40 | - case 's' : |
|---|
| 41 | - if ( preg_match( "/^{$badions[1]}:[0-9]+:.*[;}]\$/s", $data ) ) |
|---|
| 42 | - return true; |
|---|
| 43 | - break; |
|---|
| 44 | + return (bool) preg_match( "/^{$token}:[0-9]+:/s", $data ); |
|---|
| 45 | case 'b' : |
|---|
| 46 | case 'i' : |
|---|
| 47 | case 'd' : |
|---|
| 48 | - if ( preg_match( "/^{$badions[1]}:[0-9.E-]+;\$/", $data ) ) |
|---|
| 49 | - return true; |
|---|
| 50 | - break; |
|---|
| 51 | + return (bool) preg_match( "/^{$token}:[0-9.E-]+;\$/", $data ); |
|---|
| 52 | } |
|---|
| 53 | return false; |
|---|
| 54 | } |
|---|