Skip to content

Commit dc7228f

Browse files
committed
Speed optimizations for is_serialized_string(). fixes #17129
git-svn-id: https://develop.svn.wordpress.org/trunk@17779 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 8f40a55 commit dc7228f

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

wp-includes/functions.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,19 @@ function is_serialized_string( $data ) {
278278
if ( !is_string( $data ) )
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

286296
/**

0 commit comments

Comments
 (0)