Make WordPress Core

Changeset 47454


Ignore:
Timestamp:
03/13/2020 09:12:01 PM (7 years ago)
Author:
SergeyBiryukov
Message:

General: Trim the input data in maybe_unserialize(), for consistency with is_serialized().

Props pbearne, mikeschroder.
Fixes #36416.

Location:
trunk
Files:
2 edited

Legend:

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

    r47453 r47454  
    617617function maybe_unserialize( $data ) {
    618618        if ( is_serialized( $data ) ) { // Don't attempt to unserialize data that wasn't serialized going in.
    619                 return @unserialize( $data );
     619                return @unserialize( trim( $data ) );
    620620        }
    621621
  • trunk/tests/phpunit/tests/functions.php

    r47452 r47454  
    292292                                true,
    293293                        ),
     294                        array( '   s:25:"this string is serialized";   ', true ),
    294295                );
    295296        }
Note: See TracChangeset for help on using the changeset viewer.