Make WordPress Core


Ignore:
Timestamp:
04/30/2012 12:19:32 AM (13 years ago)
Author:
nacin
Message:

Check for the existence of a post before calling current_user_can() with a meta cap on that object. fixes #20336.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/class-wp-xmlrpc-server.php

    r20636 r20637  
    832832
    833833        if ( $update ) {
     834            if ( ! get_post( $post_data['ID'] ) )
     835                return new IXR_Error( 401, __( 'Invalid post ID.' ) );
    834836            if ( ! current_user_can( $post_type->cap->edit_post, $post_data['ID'] ) )
    835837                return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
     
    18151817        }
    18161818
     1819        $page = get_page($page_id);
     1820        if ( ! $page )
     1821            return new IXR_Error( 404, __( 'Invalid post ID.' ) );
     1822
    18171823        if ( !current_user_can( 'edit_page', $page_id ) )
    18181824            return new IXR_Error( 401, __( 'Sorry, you cannot edit this page.' ) );
    18191825
    18201826        do_action('xmlrpc_call', 'wp.getPage');
    1821 
    1822         // Lookup page info.
    1823         $page = get_page($page_id);
    18241827
    18251828        // If we found the page then format the data.
     
    32693272            return $this->error;
    32703273
     3274        $post_data = wp_get_single_post($post_ID, ARRAY_A);
     3275        if ( ! $post_data )
     3276            return new IXR_Error( 404, __( 'Invalid post ID.' ) );
     3277           
    32713278        if ( !current_user_can( 'edit_post', $post_ID ) )
    32723279            return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) );
    32733280
    32743281        do_action('xmlrpc_call', 'blogger.getPost');
    3275 
    3276         $post_data = wp_get_single_post($post_ID, ARRAY_A);
    32773282
    32783283        $categories = implode(',', wp_get_post_categories($post_ID));
     
    42194224            return $this->error;
    42204225
     4226        $postdata = wp_get_single_post($post_ID, ARRAY_A);
     4227        if ( ! $postdata )
     4228            return new IXR_Error( 404, __( 'Invalid post ID.' ) );
     4229
    42214230        if ( !current_user_can( 'edit_post', $post_ID ) )
    42224231            return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) );
    42234232
    42244233        do_action('xmlrpc_call', 'metaWeblog.getPost');
    4225 
    4226         $postdata = wp_get_single_post($post_ID, ARRAY_A);
    42274234
    42284235        if ($postdata['post_date'] != '') {
     
    46874694            return $this->error;
    46884695
     4696        if ( ! get_post( $post_ID ) )
     4697            return new IXR_Error( 404, __( 'Invalid post ID.' ) );
     4698
    46894699        if ( !current_user_can( 'edit_post', $post_ID ) )
    46904700            return new IXR_Error( 401, __( 'Sorry, you can not edit this post.' ) );
     
    47304740        do_action('xmlrpc_call', 'mt.setPostCategories');
    47314741
     4742        if ( ! get_post( $post_ID ) )
     4743            return new IXR_Error( 404, __( 'Invalid post ID.' ) );
     4744
    47324745        if ( !current_user_can('edit_post', $post_ID) )
    47334746            return new IXR_Error(401, __('Sorry, you cannot edit this post.'));
     
    48374850        do_action('xmlrpc_call', 'mt.publishPost');
    48384851
     4852        $postdata = wp_get_single_post($post_ID, ARRAY_A);
     4853        if ( ! $postdata )
     4854            return new IXR_Error( 404, __( 'Invalid post ID.' ) );
     4855
    48394856        if ( !current_user_can('publish_posts') || !current_user_can('edit_post', $post_ID) )
    48404857            return new IXR_Error(401, __('Sorry, you cannot publish this post.'));
    4841 
    4842         $postdata = wp_get_single_post($post_ID,ARRAY_A);
    48434858
    48444859        $postdata['post_status'] = 'publish';
Note: See TracChangeset for help on using the changeset viewer.