From b8d6fd57e55401d718940f996b2cb2070d297370 Mon Sep 17 00:00:00 2001 From: whyisjake Date: Thu, 29 Oct 2020 19:06:19 +0000 Subject: [PATCH] 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 4.3 branch. Props xknown, zieladam, peterwilsoncc, whyisjake, desrosj, dd32. Built from https://develop.svn.wordpress.org/branches/4.3@49403 git-svn-id: http://core.svn.wordpress.org/branches/4.3@49162 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/admin-header.php | 14 +++++++------- wp-admin/custom-background.php | 1 + wp-admin/custom-header.php | 2 +- wp-admin/includes/media.php | 2 +- wp-admin/includes/ms.php | 2 +- wp-admin/includes/template.php | 12 ++++++------ wp-admin/js/custom-background.js | 2 ++ wp-admin/js/custom-background.min.js | 2 +- wp-admin/js/media-gallery.js | 4 +++- wp-admin/js/media-gallery.min.js | 2 +- wp-admin/media-new.php | 4 ++-- wp-admin/network/site-users.php | 2 +- wp-includes/class-wp-xmlrpc-server.php | 19 ++++++++++++++++++- wp-includes/formatting.php | 13 +++++++------ wp-includes/meta.php | 5 +++-- 15 files changed, 55 insertions(+), 31 deletions(-) diff --git a/wp-admin/admin-header.php b/wp-admin/admin-header.php index e471ff931d..70a9baec16 100644 --- a/wp-admin/admin-header.php +++ b/wp-admin/admin-header.php @@ -70,13 +70,13 @@ wp_enqueue_script( 'svg-painter' ); $admin_body_class = preg_replace('/[^a-z0-9_-]+/i', '-', $hook_suffix); ?> diff --git a/wp-admin/custom-background.php b/wp-admin/custom-background.php index 36a5b504fa..ebdffd3c8c 100644 --- a/wp-admin/custom-background.php +++ b/wp-admin/custom-background.php @@ -460,6 +460,7 @@ if ( current_theme_supports( 'custom-background', 'default-color' ) ) * @deprecated 3.5.0 */ public function wp_set_background_image() { + check_ajax_referer( 'custom-background' ); if ( ! current_user_can('edit_theme_options') || ! isset( $_POST['attachment_id'] ) ) exit; $attachment_id = absint($_POST['attachment_id']); /** This filter is documented in wp-admin/includes/media.php */ diff --git a/wp-admin/custom-header.php b/wp-admin/custom-header.php index e61feb781c..4137bd5441 100644 --- a/wp-admin/custom-header.php +++ b/wp-admin/custom-header.php @@ -320,7 +320,7 @@ class Custom_Image_Header { ?> 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();}}}; function tb_close(){var win=window.dialogArguments||opener||parent||top;win.tb_remove();} -var ajaxurl = '', - pagenow = 'id; ?>', - typenow = 'post_type; ?>', - adminpage = '', - thousandsSeparator = 'number_format['thousands_sep'] ); ?>', - decimalPoint = 'number_format['decimal_point'] ); ?>', +var ajaxurl = '', + pagenow = 'id ); ?>', + typenow = 'post_type ); ?>', + adminpage = '', + thousandsSeparator = 'number_format['thousands_sep'] ); ?>', + decimalPoint = 'number_format['decimal_point'] ); ?>', isRtl = ; - +
diff --git a/wp-admin/network/site-users.php b/wp-admin/network/site-users.php index 6920cb1de6..d8e0b6a01b 100644 --- a/wp-admin/network/site-users.php +++ b/wp-admin/network/site-users.php @@ -179,7 +179,7 @@ if ( ! wp_is_large_network( 'users' ) && apply_filters( 'show_network_site_users require( ABSPATH . 'wp-admin/admin-header.php' ); ?> diff --git a/wp-includes/class-wp-xmlrpc-server.php b/wp-includes/class-wp-xmlrpc-server.php index 1c124593a3..1f563cefbc 100644 --- a/wp-includes/class-wp-xmlrpc-server.php +++ b/wp-includes/class-wp-xmlrpc-server.php @@ -3483,6 +3483,21 @@ class wp_xmlrpc_server extends IXR_Server { if ( ! get_post($post_id) ) return new IXR_Error( 404, __( 'Invalid post ID.' ) ); + if ( + 'publish' === get_post_status( $post_id ) && + ! current_user_can( 'edit_post', $post_id ) && + post_password_required( $post_id ) + ) { + return new IXR_Error( 403, __( 'Sorry, you are not allowed to comment on this post.' ) ); + } + + if ( + 'private' === get_post_status( $post_id ) && + ! current_user_can( 'read_post', $post_id ) + ) { + return new IXR_Error( 403, __( 'Sorry, you are not allowed to comment on this post.' ) ); + } + $comment = array(); $comment['comment_post_ID'] = $post_id; @@ -3847,8 +3862,10 @@ class wp_xmlrpc_server extends IXR_Server { /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ do_action( 'xmlrpc_call', 'wp.getMediaItem' ); - if ( ! $attachment = get_post($attachment_id) ) + $attachment = get_post( $attachment_id ); + if ( ! $attachment || 'attachment' !== $attachment->post_type ) { return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); + } return $this->_prepare_media_item( $attachment ); } diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index ac44100084..39c889bcae 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -1004,9 +1004,9 @@ function wp_check_invalid_utf8( $string, $strip = false ) { * @return string String with Unicode encoded for URI. */ function utf8_uri_encode( $utf8_string, $length = 0 ) { - $unicode = ''; - $values = array(); - $num_octets = 1; + $unicode = ''; + $values = array(); + $num_octets = 1; $unicode_length = 0; mbstring_binary_safe_encoding(); @@ -1018,9 +1018,10 @@ function utf8_uri_encode( $utf8_string, $length = 0 ) { $value = ord( $utf8_string[ $i ] ); if ( $value < 128 ) { - if ( $length && ( $unicode_length >= $length ) ) + if ( $length && ( $unicode_length >= $length ) ) { break; - $unicode .= chr($value); + } + $unicode .= chr( $value ); $unicode_length++; } else { if ( count( $values ) == 0 ) { @@ -1540,7 +1541,7 @@ function sanitize_title_with_dashes( $title, $raw_title = '', $context = 'displa if (function_exists('mb_strtolower')) { $title = mb_strtolower($title, 'UTF-8'); } - $title = utf8_uri_encode($title, 200); + $title = utf8_uri_encode( $title, 200 ); } $title = strtolower($title); diff --git a/wp-includes/meta.php b/wp-includes/meta.php index a0700b07b4..0eadb902b1 100644 --- a/wp-includes/meta.php +++ b/wp-includes/meta.php @@ -1635,8 +1635,9 @@ function _get_meta_table($type) { * @param string|null $meta_type * @return bool True if the key is protected, false otherwise. */ -function is_protected_meta( $meta_key, $meta_type = null ) { - $protected = ( '_' == $meta_key[0] ); +function is_protected_meta( $meta_key, $meta_type = '' ) { + $sanitized_key = preg_replace( "/[^\x20-\x7E\p{L}]/", '', $meta_key ); + $protected = strlen( $sanitized_key ) > 0 && ( '_' === $sanitized_key[0] ); /** * Filter whether a meta key is protected.