Skip to content
Permalink
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
  • Loading branch information...
SergeyBiryukov committed Aug 5, 2019
1 parent 9bb2eea commit fad1821dd7028a70558f7be40bb037b31c19084e
Showing with 15 additions and 1 deletion.
  1. +1 −1 src/wp-includes/functions.php
  2. +14 −0 tests/phpunit/tests/functions.php
@@ -528,7 +528,7 @@ function is_serialized( $data, $strict = true ) {
case 'i':
case 'd':
$end = $strict ? '$' : '';
return (bool) preg_match( "/^{$token}:[0-9.E-]+;$end/", $data );
return (bool) preg_match( "/^{$token}:[0-9.E+-]+;$end/", $data );
}
return false;
}
@@ -229,6 +229,20 @@ function test_is_serialized() {
}
}
/**
* @ticket 46570
*/
function test_is_serialized_should_return_true_for_large_floats() {
$cases = array(
serialize( 1.7976931348623157E+308 ),
serialize( array( 1.7976931348623157E+308, 1.23e50 ) )
);
foreach ( $cases as $case ) {
$this->assertTrue( is_serialized( $case ), "Serialized data: $case" );
}
}
/**
* @ticket 17375
*/

0 comments on commit fad1821

Please sign in to comment.
You can’t perform that action at this time.