WordPress.org

Make WordPress Core

Changeset 45754


Ignore:
Timestamp:
08/05/2019 01:54:43 PM (4 months ago)
Author:
SergeyBiryukov
Message:

General: Correctly detect large floats in is_serialized().

Props killerbishop, donmhico, hoythan.
Fixes #46570.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/functions.php

    r45742 r45754  
    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;
  • trunk/tests/phpunit/tests/functions.php

    r45607 r45754  
    227227        foreach ( $not_serialized as $case ) {
    228228            $this->assertFalse( is_serialized( $case ), "Test data: $case" );
     229        }
     230    }
     231
     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" );
    229243        }
    230244    }
Note: See TracChangeset for help on using the changeset viewer.