Make WordPress Core

Changeset 49409 for branches/3.7


Ignore:
Timestamp:
10/29/2020 07:17:08 PM (5 years ago)
Author:
whyisjake
Message:

General: WordPress updates

  • XML-RPC: Improve error messages for unprivileged users.
  • External Libraries: Disable deserialization in Requests_Utility_FilteredIterator
  • Embeds: Disable embeds on deactivated Multisite sites.
  • Coding standards: Modify escaping functions to avoid potential false positives.
  • XML-RPC: Return error message if attachment ID is incorrect.
  • Upgrade/install: Improve logic check when determining installation status.
  • Meta: Sanitize meta key before checking protection status.
  • Themes: Ensure that only privileged users can set a background image when a theme is using the deprecated custom background page.

Brings the changes from [49380,49382-49388] to the 3.7 branch.

Props xknown, zieladam, peterwilsoncc, whyisjake, desrosj, dd32.

Location:
branches/3.7
Files:
1 added
14 edited

Legend:

Unmodified
Added
Removed
  • branches/3.7

  • branches/3.7/src

  • branches/3.7/src/wp-admin/admin-header.php

    r25616 r49409  
    5858?>
    5959<script type="text/javascript">
    60 addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
    61 var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>',
    62     pagenow = '<?php echo $current_screen->id; ?>',
    63     typenow = '<?php echo $current_screen->post_type; ?>',
    64     adminpage = '<?php echo $admin_body_class; ?>',
    65     thousandsSeparator = '<?php echo addslashes( $wp_locale->number_format['thousands_sep'] ); ?>',
    66     decimalPoint = '<?php echo addslashes( $wp_locale->number_format['decimal_point'] ); ?>',
     60addLoadEvent = function(func){if(typeof jQuery!=='undefined')jQuery(document).ready(func);else if(typeof wpOnload!=='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
     61var ajaxurl = '<?php echo esc_js( admin_url( 'admin-ajax.php', 'relative' ) ); ?>',
     62    pagenow = '<?php echo esc_js( $current_screen->id ); ?>',
     63    typenow = '<?php echo esc_js( $current_screen->post_type ); ?>',
     64    adminpage = '<?php echo esc_js( $admin_body_class ); ?>',
     65    thousandsSeparator = '<?php echo esc_js( $wp_locale->number_format['thousands_sep'] ); ?>',
     66    decimalPoint = '<?php echo esc_js( $wp_locale->number_format['decimal_point'] ); ?>',
    6767    isRtl = <?php echo (int) is_rtl(); ?>;
    6868</script>
  • branches/3.7/src/wp-admin/custom-background.php

    r25868 r49409  
    411411
    412412    public function wp_set_background_image() {
     413        check_ajax_referer( 'custom-background' );
    413414        if ( ! current_user_can('edit_theme_options') || ! isset( $_POST['attachment_id'] ) ) exit;
    414415        $attachment_id = absint($_POST['attachment_id']);
  • branches/3.7/src/wp-admin/custom-header.php

    r25868 r49409  
    321321/* <![CDATA[ */
    322322(function($){
    323     var default_color = '#<?php echo get_theme_support( 'custom-header', 'default-text-color' ); ?>',
     323    var default_color = '#<?php echo esc_js( get_theme_support( 'custom-header', 'default-text-color' ) ); ?>',
    324324        header_text_fields;
    325325
  • branches/3.7/src/wp-admin/includes/media.php

    r47962 r49409  
    393393//<![CDATA[
    394394addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
    395 var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>', pagenow = 'media-upload-popup', adminpage = 'media-upload-popup',
     395var ajaxurl = '<?php echo esc_js( admin_url( 'admin-ajax.php', 'relative' ) ); ?>', pagenow = 'media-upload-popup', adminpage = 'media-upload-popup',
    396396isRtl = <?php echo (int) is_rtl(); ?>;
    397397//]]>
  • branches/3.7/src/wp-admin/includes/template.php

    r41456 r49409  
    14171417addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
    14181418function tb_close(){var win=window.dialogArguments||opener||parent||top;win.tb_remove();}
    1419 var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>',
    1420     pagenow = '<?php echo $current_screen->id; ?>',
    1421     typenow = '<?php echo $current_screen->post_type; ?>',
    1422     adminpage = '<?php echo $admin_body_class; ?>',
    1423     thousandsSeparator = '<?php echo addslashes( $wp_locale->number_format['thousands_sep'] ); ?>',
    1424     decimalPoint = '<?php echo addslashes( $wp_locale->number_format['decimal_point'] ); ?>',
     1419var ajaxurl = '<?php echo esc_js( admin_url( 'admin-ajax.php', 'relative' ) ); ?>',
     1420    pagenow = '<?php echo esc_js( $current_screen->id ); ?>',
     1421    typenow = '<?php echo esc_js( $current_screen->post_type ); ?>',
     1422    adminpage = '<?php echo esc_js( $admin_body_class ); ?>',
     1423    thousandsSeparator = '<?php echo esc_js( $wp_locale->number_format['thousands_sep'] ); ?>',
     1424    decimalPoint = '<?php echo esc_js( $wp_locale->number_format['decimal_point'] ); ?>',
    14251425    isRtl = <?php echo (int) is_rtl(); ?>;
    14261426//]]>
  • branches/3.7/src/wp-admin/js/custom-background.js

    r23092 r49409  
    5656                // Grab the selected attachment.
    5757                var attachment = frame.state().get('selection').first();
     58                var nonceValue = $( '#_wpnonce' ).val() || '';
    5859
    5960                // Run an AJAX request to set the background image.
     
    6162                    action: 'set-background-image',
    6263                    attachment_id: attachment.id,
     64                    _ajax_nonce: nonceValue,
    6365                    size: 'full'
    6466                }).done( function() {
  • branches/3.7/src/wp-admin/js/media-gallery.js

    r21592 r49409  
    11jQuery(function($){
    22    $( 'body' ).bind( 'click.wp-gallery', function(e){
    3         var target = $( e.target ), id, img_size;
     3        var target = $( e.target ), id, img_size, nonceValue;
    44
    55        if ( target.hasClass( 'wp-set-header' ) ) {
     
    99            id = target.data( 'attachment-id' );
    1010            img_size = $( 'input[name="attachments[' + id + '][image-size]"]:checked').val();
     11            nonceValue = $( '#_wpnonce' ).val() && '';
    1112
    1213            jQuery.post(ajaxurl, {
    1314                action: 'set-background-image',
    1415                attachment_id: id,
     16                _ajax_nonce: nonceValue,
    1517                size: img_size
    1618            }, function(){
  • branches/3.7/src/wp-admin/media-new.php

    r25616 r49409  
    7474
    7575    <script type="text/javascript">
    76     var post_id = <?php echo $post_id; ?>, shortform = 3;
     76    var post_id = <?php echo absint( $post_id ); ?>, shortform = 3;
    7777    </script>
    78     <input type="hidden" name="post_id" id="post_id" value="<?php echo $post_id; ?>" />
     78    <input type="hidden" name="post_id" id="post_id" value="<?php echo absint( $post_id ); ?>" />
    7979    <?php wp_nonce_field('media-form'); ?>
    8080    <div id="media-items" class="hide-if-no-js"></div>
  • branches/3.7/src/wp-admin/network/site-users.php

    r25616 r49409  
    172172<script type='text/javascript'>
    173173/* <![CDATA[ */
    174 var current_site_id = <?php echo $id; ?>;
     174var current_site_id = <?php echo absint( $id ); ?>;
    175175/* ]]> */
    176176</script>
  • branches/3.7/src/wp-includes/class-wp-xmlrpc-server.php

    r40703 r49409  
    30423042            return new IXR_Error( 404, __( 'Invalid post ID.' ) );
    30433043
     3044        if (
     3045            'publish' === get_post_status( $post_id ) &&
     3046            ! current_user_can( 'edit_post', $post_id ) &&
     3047            post_password_required( $post_id )
     3048        ) {
     3049            return new IXR_Error( 403, __( 'Sorry, you are not allowed to comment on this post.' ) );
     3050        }
     3051
     3052        if (
     3053            'private' === get_post_status( $post_id ) &&
     3054            ! current_user_can( 'read_post', $post_id )
     3055        ) {
     3056            return new IXR_Error( 403, __( 'Sorry, you are not allowed to comment on this post.' ) );
     3057        }
     3058
     3059        $comment = array();
    30443060        $comment['comment_post_ID'] = $post_id;
    30453061
     
    33503366        do_action('xmlrpc_call', 'wp.getMediaItem');
    33513367
    3352         if ( ! $attachment = get_post($attachment_id) )
     3368        $attachment = get_post( $attachment_id );
     3369        if ( ! $attachment || 'attachment' !== $attachment->post_type ) {
    33533370            return new IXR_Error( 404, __( 'Invalid attachment ID.' ) );
     3371        }
    33543372
    33553373        return $this->_prepare_media_item( $attachment );
  • branches/3.7/src/wp-includes/meta.php

    r47343 r49409  
    892892 * @return bool True if the key is protected, false otherwise.
    893893 */
    894 function is_protected_meta( $meta_key, $meta_type = null ) {
    895     $protected = ( '_' == $meta_key[0] );
     894function is_protected_meta( $meta_key, $meta_type = '' ) {
     895    $sanitized_key = preg_replace( "/[^\x20-\x7E\p{L}]/", '', $meta_key );
     896    $protected     = strlen( $sanitized_key ) > 0 && ( '_' === $sanitized_key[0] );
    896897
    897898    return apply_filters( 'is_protected_meta', $protected, $meta_key, $meta_type );
  • branches/3.7/tests/phpunit/tests/formatting/Utf8UriEncode.php

    r25002 r49409  
    1313     */
    1414    function test_percent_encodes_non_reserved_characters( $utf8, $urlencoded ) {
    15         $this->assertEquals($urlencoded, utf8_uri_encode( $utf8 ) );
     15        $this->assertEquals( $urlencoded, utf8_uri_encode( $utf8 ) );
    1616    }
    1717
Note: See TracChangeset for help on using the changeset viewer.