Changeset 25320
- Timestamp:
- 09/10/2013 06:09:36 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/functions.php
r25318 r25320 243 243 * 244 244 * @param mixed $data Value to check to see if was serialized. 245 * @param bool $strict Optional. Whether to be strict about the end of the string. Defaults true. 245 246 * @return bool False if not serialized and true if it was. 246 247 */ 247 function is_serialized( $data ) {248 function is_serialized( $data, $strict = true ) { 248 249 // if it isn't a string, it isn't serialized 249 250 if ( ! is_string( $data ) ) … … 257 258 if ( ':' !== $data[1] ) 258 259 return false; 259 $lastc = $data[$length-1]; 260 if ( ';' !== $lastc && '}' !== $lastc ) 261 return false; 260 if ( $strict ) { 261 $lastc = $data[ $length - 1 ]; 262 if ( ';' !== $lastc && '}' !== $lastc ) 263 return false; 264 } else { 265 // ensures ; or } exists but is not in the first X chars 266 if ( strpos( $data, ';' ) < 3 && strpos( $data, '}' ) < 4 ) 267 return false; 268 } 262 269 $token = $data[0]; 263 270 switch ( $token ) { 264 271 case 's' : 265 if ( '"' !== $data[$length-2] ) 272 if ( $strict ) { 273 if ( '"' !== $data[ $length - 2 ] ) 274 return false; 275 } elseif ( false === strpos( $data, '"' ) ) { 266 276 return false; 277 } 267 278 case 'a' : 268 279 case 'O' : … … 271 282 case 'i' : 272 283 case 'd' : 273 return (bool) preg_match( "/^{$token}:[0-9.E-]+;\$/", $data ); 284 $end = $strict ? '$' : ''; 285 return (bool) preg_match( "/^{$token}:[0-9.E-]+;$end/", $data ); 274 286 } 275 287 return false; … … 318 330 // Double serialization is required for backward compatibility. 319 331 // See http://core.trac.wordpress.org/ticket/12930 320 if ( is_serialized( $data ) )332 if ( is_serialized( $data, false ) ) 321 333 return serialize( $data ); 322 334
Note: See TracChangeset
for help on using the changeset viewer.