Make WordPress Core

Ticket #5782: 5782.diff

File 5782.diff, 6.0 KB (added by mdawaffe, 18 years ago)
  • wp-includes/js/autosave.js

     
    3636                jQuery.post(autosaveL10n.requestFile, {
    3737                        action: "autosave-generate-nonces",
    3838                        post_ID: res,
    39                         cookie: document.cookie,
     39                        autosavenonce: jQuery('#autosavenonce').val(),
    4040                        post_type: jQuery('#post_type').val()
    4141                }, function(html) {
    4242                        jQuery('#_wpnonce').val(html);
     
    8787                        action: "autosave",
    8888                        post_ID:  jQuery("#post_ID").val() || 0,
    8989                        post_title: jQuery("#title").val() || "",
    90                         cookie: document.cookie,
     90                        autosavenonce: jQuery('#autosavenonce').val(),
    9191                        tags_input: jQuery("#tags-input").val() || "",
    9292                        post_type: jQuery('#post_type').val() || ""
    9393                };
     
    9999                tinyMCE.triggerSave();
    100100        }
    101101       
    102     post_data["content"] = jQuery("#content").val();
     102        post_data["content"] = jQuery("#content").val();
    103103
    104104        if(post_data["post_title"].length==0 || post_data["content"].length==0 || post_data["post_title"] + post_data["content"] == autosaveLast) {
    105105                return;
  • wp-includes/pluggable.php

     
    635635 * @uses do_action() Calls 'check_admin_referer' on $action.
    636636 *
    637637 * @param string $action Action nonce
     638 * @param string $query_arg where to look for nonce in $_REQUEST (since 2.5)
    638639 */
    639 function check_admin_referer($action = -1) {
     640function check_admin_referer($action = -1, $query_arg = '_wpnonce' ) {
    640641        $adminurl = strtolower(get_option('siteurl')).'/wp-admin';
    641642        $referer = strtolower(wp_get_referer());
    642         if ( !wp_verify_nonce($_REQUEST['_wpnonce'], $action) &&
     643        if ( !wp_verify_nonce($_REQUEST[$query_arg], $action) &&
    643644                !(-1 == $action && strpos($referer, $adminurl) !== false)) {
    644645                wp_nonce_ays($action);
    645646                die();
     
    654655 * @since 2.0.4
    655656 *
    656657 * @param string $action Action nonce
     658 * @param string $query_arg where to look for nonce in $_REQUEST (since 2.5)
    657659 */
    658 function check_ajax_referer( $action = -1 ) {
    659         $nonce = $_REQUEST['_ajax_nonce'] ? $_REQUEST['_ajax_nonce'] : $_REQUEST['_wpnonce'];
    660         if ( !wp_verify_nonce( $nonce, $action ) ) {
    661                 $current_id = '';
    662                 if ( ( $current = wp_get_current_user() ) && $current->ID )
    663                         $current_id = $current->ID;
    664                 if ( !$current_id )
    665                         die('-1');
     660function check_ajax_referer( $action = -1, $query_arg = false ) {
     661        if ( $query_arg )
     662                $nonce = $_REQUEST[$query_arg];
     663        else
     664                $nonce = $_REQUEST['_ajax_nonce'] ? $_REQUEST['_ajax_nonce'] : $_REQUEST['_wpnonce'];
    666665
    667                 $auth_cookie = '';
    668                 $cookie = explode('; ', urldecode(empty($_POST['cookie']) ? $_GET['cookie'] : $_POST['cookie'])); // AJAX scripts must pass cookie=document.cookie
    669                 foreach ( $cookie as $tasty ) {
    670                         if ( false !== strpos($tasty, AUTH_COOKIE . '=') ) {
    671                                 $auth_cookie = substr(strstr($tasty, '='), 1);
    672                                 break;
    673                         }
    674                 }
     666        if ( !wp_verify_nonce( $nonce, $action ) )
     667                die('-1');
    675668
    676                 if ( empty($auth_cookie) )
    677                         die('-1');
    678 
    679                 if ( ! $user_id = wp_validate_auth_cookie( $auth_cookie ) )
    680                         die('-1');
    681 
    682                 if ( $current_id != $user_id )
    683                         die('-1');
    684         }
    685669        do_action('check_ajax_referer');
    686670}
    687671endif;
  • wp-includes/script-loader.php

     
    3737
    3838                $this->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.6');
    3939
    40                 $this->add( 'autosave', '/wp-includes/js/autosave.js', array('jquery', 'schedule'), '20080104');
     40                $this->add( 'autosave', '/wp-includes/js/autosave.js', array('jquery', 'schedule'), '20080206');
    4141                $this->localize( 'autosave', 'autosaveL10n', array(
    4242                        'autosaveInterval' => apply_filters('autosave_interval', '120'),
    4343                        'errorText' => __('Error: %response%'),
  • wp-admin/admin-ajax.php

     
    467467        $x->send();
    468468        break;
    469469case 'autosave' : // The name of this action is hardcoded in edit_post()
    470         check_ajax_referer( $action );
     470        check_ajax_referer( 'autosave', 'autosavenonce' );
    471471        $_POST['post_content'] = $_POST['content'];
    472472        $_POST['post_excerpt'] = $_POST['excerpt'];
    473473        $_POST['post_status'] = 'draft';
     
    499499        die('0');
    500500break;
    501501case 'autosave-generate-nonces' :
    502         check_ajax_referer( $action );
     502        check_ajax_referer( 'autosave', 'autosavenonce' );
    503503        $ID = (int) $_POST['post_ID'];
    504504        if($_POST['post_type'] == 'post') {
    505505                if(current_user_can('edit_post', $ID))
  • wp-admin/edit-page-form.php

     
    5656<div id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>" class="postarea">
    5757<h3><?php _e('Page') ?></h3>
    5858<?php the_editor($post->post_content); ?>
     59<?php wp_nonce_field( 'autosave', 'autosavenonce', false ); ?>
    5960</div>
    6061
    6162<div id="submitpost">
  • wp-admin/edit-form.php

     
    3939 }
    4040?>
    4141<div><textarea rows="<?php echo $rows; ?>" cols="40" name="content" tabindex="4" id="content"><?php echo $post->post_content ?></textarea></div>
     42<?php wp_nonce_field( 'autosave', 'autosavenonce', false ); ?>
    4243</fieldset>
    4344
    4445
  • wp-admin/edit-form-advanced.php

     
    8888<div id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>" class="postarea">
    8989<h3><?php _e('Post') ?></h3>
    9090<?php the_editor($post->post_content); ?>
     91<?php wp_nonce_field( 'autosave', 'autosavenonce', false ); ?>
    9192</div>
    9293
    9394<?php echo $form_pingback ?>