Make WordPress Core

Ticket #32703: FixEditPage.patch

File FixEditPage.patch, 1.7 KB (added by redsweater, 10 years ago)

Patch to correct behavior of wp_editPage and avoid double-escaping arguments

  • wp-includes/class-wp-xmlrpc-server.php

     
    27472747         * @return array|IXR_Error
    27482748         */
    27492749        public function wp_editPage( $args ) {
    2750                 // Items not escaped here will be escaped in editPost.
    2751                 $page_id  = (int) $this->escape($args[1]);
    2752                 $username = $this->escape($args[2]);
    2753                 $password = $this->escape($args[3]);
     2750                $page_id  = $args[1];
     2751                $username = $args[2];
     2752                $password = $args[3];
    27542753                $content  = $args[4];
    27552754                $publish  = $args[5];
    27562755
    2757                 if ( !$user = $this->login($username, $password) )
     2756                // Escape arguments for our own purposes but leave originals intact
     2757                // to avoid double-escaping in mw_editPost
     2758                $escaped_page_id = (int) $this->escape($page_id);
     2759                $escaped_username = $this->escape($username);
     2760                $escaped_password = $this->escape($password);
     2761
     2762                if ( !$user = $this->login($escaped_username, $escaped_password) )
    27582763                        return $this->error;
    27592764
    27602765                /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    27612766                do_action( 'xmlrpc_call', 'wp.editPage' );
    27622767
    27632768                // Get the page data and make sure it is a page.
    2764                 $actual_page = get_post($page_id, ARRAY_A);
     2769                $actual_page = get_post($escaped_page_id, ARRAY_A);
    27652770                if ( !$actual_page || ($actual_page['post_type'] != 'page') )
    27662771                        return new IXR_Error( 404, __( 'Sorry, no such page.' ) );
    27672772
    27682773                // Make sure the user is allowed to edit pages.
    2769                 if ( !current_user_can('edit_page', $page_id) )
     2774                if ( !current_user_can('edit_page', $escaped_page_id) )
    27702775                        return new IXR_Error( 401, __( 'Sorry, you do not have the right to edit this page.' ) );
    27712776
    27722777                // Mark this as content for a page.