Skip to content

Commit fad1821

Browse files
General: Correctly detect large floats in is_serialized().
Props killerbishop, donmhico, hoythan. Fixes #46570. git-svn-id: https://develop.svn.wordpress.org/trunk@45754 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 9bb2eea commit fad1821

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/wp-includes/functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ function is_serialized( $data, $strict = true ) {
528528
case 'i':
529529
case 'd':
530530
$end = $strict ? '$' : '';
531-
return (bool) preg_match( "/^{$token}:[0-9.E-]+;$end/", $data );
531+
return (bool) preg_match( "/^{$token}:[0-9.E+-]+;$end/", $data );
532532
}
533533
return false;
534534
}

tests/phpunit/tests/functions.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,20 @@ function test_is_serialized() {
229229
}
230230
}
231231

232+
/**
233+
* @ticket 46570
234+
*/
235+
function test_is_serialized_should_return_true_for_large_floats() {
236+
$cases = array(
237+
serialize( 1.7976931348623157E+308 ),
238+
serialize( array( 1.7976931348623157E+308, 1.23e50 ) )
239+
);
240+
241+
foreach ( $cases as $case ) {
242+
$this->assertTrue( is_serialized( $case ), "Serialized data: $case" );
243+
}
244+
}
245+
232246
/**
233247
* @ticket 17375
234248
*/

0 commit comments

Comments
 (0)