Make WordPress Core

Changeset 19707


Ignore:
Timestamp:
01/08/2012 03:48:05 AM (15 years ago)
Author:
dd32
Message:

use maybe_unserialize() in update and API checks, Tighten up the checks on expected return data to avoid processing invalid responses after change. See #19617

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/plugin-install.php

    r19627 r19707  
    4646                        $res = new WP_Error('plugins_api_failed', __('An Unexpected HTTP Error occurred during the API request.'), $request->get_error_message() );
    4747                } else {
    48                         $res = unserialize( wp_remote_retrieve_body( $request ) );
    49                         if ( false === $res )
    50                                 $res = new WP_Error('plugins_api_failed', __('An unknown error occurred.'), wp_remote_retrieve_body( $request ) );
     48                        $res = maybe_unserialize( wp_remote_retrieve_body( $request ) );
     49                        if ( ! is_object( $res ) && ! is_array( $res ) )
     50                                $res = new WP_Error('plugins_api_failed', __('An unknown error occurred during the API request.'), wp_remote_retrieve_body( $request ) );
    5151                }
    5252        } elseif ( !is_wp_error($res) ) {
  • trunk/wp-admin/includes/theme.php

    r19684 r19707  
    410410                        $res = new WP_Error('themes_api_failed', __('An Unexpected HTTP Error occurred during the API request.'), $request->get_error_message() );
    411411                } else {
    412                         $res = unserialize( wp_remote_retrieve_body( $request ) );
    413                         if ( ! $res )
    414                         $res = new WP_Error('themes_api_failed', __('An unknown error occurred.'), wp_remote_retrieve_body( $request ) );
    415                 }
    416         }
    417         //var_dump(array($args, $res));
     412                        $res = maybe_unserialize( wp_remote_retrieve_body( $request ) );
     413                        if ( ! is_object( $res ) && ! is_array( $res ) )
     414                                $res = new WP_Error('themes_api_failed', __('An unknown error occurred during the API request.'), wp_remote_retrieve_body( $request ) );
     415                }
     416        }
     417
    418418        return apply_filters('themes_api_result', $res, $action, $args);
    419419}
  • trunk/wp-includes/update.php

    r19693 r19707  
    9292
    9393        $body = trim( wp_remote_retrieve_body( $response ) );
    94         if ( ! $body = maybe_unserialize( $body ) )
    95                 return false;
    96         if ( ! isset( $body['offers'] ) )
    97                 return false;
     94        $body = maybe_unserialize( $body );
     95
     96        if ( ! is_array( $body ) || ! isset( $body['offers'] ) )
     97                return false;
     98
    9899        $offers = $body['offers'];
    99100
    … …  
    206207                return false;
    207208
    208         $response = unserialize( wp_remote_retrieve_body( $raw_response ) );
    209 
    210         if ( false !== $response )
     209        $response = maybe_unserialize( wp_remote_retrieve_body( $raw_response ) );
     210
     211        if ( is_array( $response ) )
    211212                $new_option->response = $response;
    212213        else
    … …  
    320321        $new_update->checked = $checked;
    321322
    322         $response = unserialize( wp_remote_retrieve_body( $raw_response ) );
    323         if ( false !== $response )
     323        $response = maybe_unserialize( wp_remote_retrieve_body( $raw_response ) );
     324        if ( is_array( $response ) )
    324325                $new_update->response = $response;
    325326
Note: See TracChangeset for help on using the changeset viewer.