### Eclipse Workspace Patch 1.0
#P wordpress-trunk
|
|
|
|
| 238 | 238 | * |
| 239 | 239 | * If $data is not an string, then returned value will always be false. |
| 240 | 240 | * Serialized data is always a string. |
| | 241 | * |
| | 242 | * NOTICE: There can be no guarantee wether the data passed was not |
| | 243 | * just a string even if it looked like it was serialized. |
| 241 | 244 | * |
| 242 | 245 | * @since 2.0.5 |
| 243 | 246 | * |
| 244 | 247 | * @param mixed $data Value to check to see if was serialized. |
| 245 | 248 | * @return bool False if not serialized and true if it was. |
| 246 | 249 | */ |
| 247 | | function is_serialized( $data ) { |
| 248 | | // if it isn't a string, it isn't serialized |
| | 250 | function is_serialized( &$data ) { |
| 249 | 251 | if ( !is_string( $data ) ) |
| 250 | 252 | return false; |
| 251 | | $data = trim( $data ); |
| 252 | | if ( 'N;' == $data ) |
| 253 | | return true; |
| 254 | | if ( !preg_match( '/^([adObis]):/', $data, $badions ) ) |
| | 253 | |
| | 254 | if ( !preg_match( '/^([abdiOs]:|N;)/', $data, $matches ) ) |
| 255 | 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; |
| | 256 | |
| | 257 | $type = $matches[1][0]; |
| | 258 | |
| | 259 | switch ( $type ) { |
| | 260 | case 'a' : # array |
| | 261 | return (bool) preg_match( '/^a:[0-9]+:{.*}$/s', $data ); |
| | 262 | case 'b' : # bool |
| | 263 | case 'd' : # double |
| | 264 | case 'i' : # integer |
| | 265 | return (bool) preg_match( "/^{$type}:[0-9.E-]+;\$/", $data ); |
| | 266 | case 'N' : # NULL |
| | 267 | return (bool) ( 'N;' == $data ); |
| | 268 | case 'O' : # object |
| | 269 | return (bool) preg_match( '/^O:[0-9]+:"[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*":[0-9]+:{.*}$/s', $data ); |
| | 270 | case 's' : # string |
| | 271 | return (bool) preg_match( '/^s:[0-9]+:".*";$/s', $data ); |
| | 272 | default: |
| | 273 | return false; |
| 269 | 274 | } |
| 270 | | return false; |
| 271 | 275 | } |
| 272 | 276 | |
| 273 | 277 | /** |