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
This commit is contained in:
parent
9bb2eea37a
commit
fad1821dd7
|
@ -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 @@ class Tests_Functions extends WP_UnitTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue